我有一些麻烦,以获得.htaccess文件的正确configuration。 我使用mvc模式制作了一个小站点,所有的url都像site.com/appname/public/index.php?param=page。 我试图让所有url写为site.com/page。 我search了Apache文档,但我仍然困惑… 这是我现在在/ public目录中的: Options -MultiViews RewriteEngine on RewriteBase /appname/public/ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] 这是我在根目录中的: RewriteEngine On RewriteRule ^(.*)$ appname/public [R=301,L] 这工作正常,它redirect到index.php(在/公共目录),并重写所有url到site.com/appname/public/page。 现在我triyng得到更多,我也会隐藏/ appname /公共,但我不能undestand如何。 我应该结合更多的RewriteRule来匹配“/ appname / public”吗? 有什么build议么? 非常感谢! 编辑:关于我想要实现的更多信息。 我有一个目录树,如: htdocs |—appname | |—app | |—other_dirs | |—other_files | |—public |—some_dirs/file |— index.php 为了访问我的网页,我需要指向浏览器index.php并传递一些GET值。 […]
起初,这个规则是有效的: DirectoryIndex index.php ErrorDocument 403 /form.html RewriteCond %{REQUEST_URI} ^/index\.php$ RewriteCond %{REQUEST_METHOD} !POST RewriteRule . – [F,L] 这意味着http://example.com和http://example.com/index.php只能通过POST打开。 现在的问题 我添加了这个额外的规则集: RewriteCond %{REQUEST_URI} !^/index\.php$ RewriteRule . – [F,L] 现在,我再次发送POST到http://example.com但收到此错误: Forbidden You don't have permission to access / on this server. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle […]
当我将域名链接到EC2实例IP时,我在同一台机器上的wordpress设置返回503错误。 它没有链接到任何域名时运行良好。 更新 :我想我find了错误的原因,这将是ELB实例获取301作为状态码,由于redirect(它必须是私人IP)。 仍然不知道如何解决这个问题。 案例: 如果我点击IP地址,它将被redirect到example.com并返回503错误。 如果我点击了example.com,它只会返回503错误。 我尝试了一系列的变化,但似乎没有一个工作。 步骤是: 在/etc/httpd/conf/httpd.conf下添加ServerName 在wp-config中添加SITE_URL和HOME_URL(以及functions.php中的相关更改 在wp_options表中更新site_url和home_url 但是这些似乎都不能解决这个问题 .htaccess文件 # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress 我原来的计划是在自动调整组下安装实例并负载均衡,但即使是基本configuration似乎也没有工作。 如果我将域名链接到ELBurl并在负载平衡器下添加实例,也会发生同样的情况。
通过主页( example.com )进入我的网站时,一切正常。 但是,当进入example.com/forums时,我得到一个500内部错误,我在error_log中看到下面的内容: 由于可能的configuration错误,请求超出了10个内部redirect的限制。 另外,我知道我可以发布httpd -S的输出,但是它真的很长,并且没有扰stream块,并且格式化消失了,对不起。 这是我的.htaccess : <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ – [NC,L] RewriteRule ^(data|js|styles|install) – [NC,L] RewriteRule ^.*$ index.php [NC,L] RewriteBase /var/www/html </IfModule> 编辑:你需要虚拟主机? <IfModule mod_rewrite.c> RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L] </IfModule>
Apache忽略我的.htaccess文件。 我已经读了或多或less关于这个问题的每一个线索,我可以find并尝试所有的解决scheme,没有任何工作。 我已经尝试过不止一次。 设置 VPS上的Ubuntu 16.04.1 LTS(GNU / Linux 4.4.0-57-generic x86_64) Apache / 2.4.18(Ubuntu) Django 1.10通过WSGI Python 3.5在virtualenv 我想提供一些文件,只能通过批准的IP范围或用户login。 我有一个.htaccess文件,我以前曾经在一个基于php的网站的虚拟主机上使用,现在我想让它在一个基于Django的网站上使用VPS。 以下目录的名称已被更改,但应忠实于设置。 文件的位置 .htaccess文件里面的/dir在一个子目录中, /dir/1/2/3 1/2/3。 我希望它将设置应用于该子目录中的每个子目录,例如/dir/1/2/3/a 1/2/3 /dir/1/2/3/a , /dir/1/2/3/b , /dir/1/2/3/c 。 这些目录具有应该被保护访问的文件(例如/dir/1/2/3/a/file.pdf )。这应该通过.htaccess来完成,而不是服务器范围的设置,因为可接受的IP列表非常长,我宁愿没有它膨胀我的Apacheconfiguration文件。 .htaccess文件 大部分内容是出于隐私原因编辑的,但是它遵循这个模板。 # initial deny <Limit GET POST> order deny,allow deny from all # SUBSCRIBER LIST #a very long list […]
我想redirect到一个查询string的URL到另一个: example.com/product-category/search/?filter_grade-level=154 至 example.com/product-category/search/?filter_grade-level=k 任何想法在.htaccess添加什么?
我试图阻止引用垃圾邮件到我运行的一些网站。 然后我在日志文件中遇到了很多这样的行。 \xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xb9\xd0\xba\xd0\xb0.kz 目前,我正在使用我的.htaccess文件中的以下行保持引荐来源垃圾邮件不出现在客户的AWStats报告中。 RewriteCond %{HTTP_REFERER} ^http(s)?:\/\/([^.]+\.)*domain\.com\/ 这似乎工作正常,但我似乎有编码的URL的问题。 如果我将URL解码为стройка.kz那么我可以使用它作为条件吗?
怎么可能有一个通配符目录代理? 我已经得到了基本的,但问题是,它给出了我的目录,我的htaccess文件: RewriteEngine on RewriteCond %{REQUEST_URI} !(u|api|fonts|images|css|js) [NC] # No directory RewriteRule ^(.*)\.(jpg|gif|png|txt|mp4|mp3|json|js|zip|bmp|tiff|webp|webm|raw|psd|jpeg|jpe|wav)(.*) http://127.0.0.1:9000/owoapi/$1.$2$3?%{QUERY_STRING} [proxy] # One Directory RewriteRule ^([^/]+)/(.*)\. (jpg|gif|png|txt|mp4|mp3|json|js|zip|bmp|tiff|webp|webm|raw|psd|jpeg|jpe|wav) (.*) http://127.0.0.1:9000/owoapi/$1.$2$3?%{QUERY_STRING} [proxy] 当访问domain.tld/image.png ,它工作得很好。 当访问domain.tld/test/image.png ,404代码是由于它包含/ test /在代理URL中,我该如何解决这个问题呢? 编辑:我试图实现的是不包括前面的URL,并使其行为像它被访问通过domain.tld/image.png而不是domain.tld/test/image.png
我试图只覆盖特定用户代理的文件的MIMEtypes(Chrome),并保留其他(Firefox)的默认值。 Options +Indexes IndexOptions -FancyIndexing Header set Access-Control-Allow-Origin "*" RewriteEngine On RewriteCond %{HTTP_HOST} !^example.org$ RewriteRule ^(.*)$ http://example.org/$1 [R=301,L] # Turn off MultiViews Options -MultiViews # Directive to ensure *.rdf files served as appropriate content type, # if not present in main apache config AddType "application/rdf+xml" .rdf AddType "text/turtle" .ttl # Rewrite engine setup RewriteBase / […]
我使用共享主机上的litespeed(不幸),我正在尝试使用.htaccess将http重写为https NON www,并且将domain.com/index目的将domain.com/my-string更改为domain.com/my-string 。 这在Apache中工作正常,我不知道我的共享主机正在使用Litespeed。 我使用相同的.htaccess litespeed结果在404,尽pipe我的文件名是正确的。 这是我的htaccess: DirectoryIndex my-string.php Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^$ my-string [L] RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] RewriteCond %{HTTPS} !on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] RewriteRule ^my-string$ /my-string.php [L] # php — BEGIN cPanel-generated handler, do not edit # Set the “ea-php56” package […]