Articles of .htaccess

如何添加一个额外的RewriteCond来排除特定的url?

我有一个现有的.htaccess文件与以下rewritecond: RewriteCond %{HTTP_HOST} !^go\.domain\.com$ [NC] RewriteRule ^(.*)$ https://go.domain.com [R,L] 本质上,这个域上的所有内容都被强制go子域。 但是,我想留下一个url,而不是重写: www.domain.com/terms 如何添加额外的RewriteCond来排除这个特定的url?

HTAccess允许使用名称作为密码login

我有一个问题,我的服务器正在接受我的网站有错误的密码。 例如,我的域名可能是“johndoe.com”,情况是 htlogin名: johndoe 密码: johndoe123 哪些工作正常login我,但是有一个小问题。 由于某种原因,我也可以使用我的login名作为密码,它会让我进入! 我尝试使用随机密码,但没有工作(预期的行为)。 我看着我的.htpasswd,它看起来像这样: johndoe:rpFVb9n8R.p9c 那么我的密码和login名是否都是正确的密码呢? 这个超出了我:/

从索引中隐藏文件夹中的每个目录,但不包括其内容

在我的服务器上,我想创build一个隐藏于普通用户的目录,但是可以通过链接进行访问而无需身份validation。 目前我已经设置了这样的: 在虚拟主机configuration中,我已经允许重写索引选项 在我的服务器上,我有文件夹名为h ,如隐藏 与h的同一级别上,我有一个.htaccess文件: IndexIgnore h 而在另一个.htaccess与IndexIgnore * 但是,这也隐藏了我不想要的h/abc/的内容。 我试着把IndexIgnore . 在h/abc/.htaccess ,但它没有工作。 HTTPD文档中也提到了这个问题,后来我学到了这一点: 多个IndexIgnore指令添加到列表中,而不是replace被忽略文件的列表。 默认情况下,列表包含。 (当前目录)。 有没有办法指定IndexIgnore只对当前目录内的项目,而不是recursion? 还是有其他更好的方法来处理这个问题? 我宁愿不要触摸“全局”configuration文件太多,尽pipe这是可能的。

htaccess重写给出LimitInternalRecursion错误

我有一个.htaccess文件与下面的代码 <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule> 但是当我访问我的网站时,我得到这个错误 [client 127.0.0.1] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace. LogLeveldebugging不会给我一个回溯,我不认为增加内部recursion限制是明智的。 有没有人有这种types的错误的经验?

htaccess中的通配符redirect

我需要做一个重写规则或redirect与通配符中包含的行。 这是我迄今为止的一个单独链接的例子。 redirect301 / actors / hey-steve-dave-454924 / http://www.mydomain.com/ 我想有类似于Redirect 301 / actors / hey-steve-dave- *的地方,其中*用/ actors / hey-steve-dave-(任意6个数字)redirect到主页。 有任何想法吗?

根据环境variables有条件地使用mod_expires

我从HTML5 Boilerplate中借用了一些mod_expires代码,它为资产到期添加了一些合理的默认值(我使用htaccessconfiguration了文件名版本转换,所以我可以在资源扩展之前添加m次,如script.123456789.js ): ExpiresActive on ExpiresDefault "access plus 1 month" # CSS ExpiresByType text/css "access plus 1 year" # Data interchange ExpiresByType application/json "access plus 0 seconds" ExpiresByType application/xml "access plus 0 seconds" ExpiresByType text/xml "access plus 0 seconds" # … etc … 但是,我想在我的开发服务器(设置一个DEVELOPMENT=1环境variables)禁用这些。 如果设置了环境variables( Allow from env=DEVELOPMENT ),是否可以在2.4.4中有条件地禁用mod_expires (也许是ExpiresActive On ),就像使用mod_access一样?

caching破坏和包含Nginx的文件

在Apache中,您可以使用以下命令来cachingcss和js文件,并使用Apache的Include mod将它们作为单个文件进行caching: <FilesMatch "\.combined\.js$"> Options +Includes AddOutputFilterByType INCLUDES application/javascript application/json SetOutputFilter INCLUDES </FilesMatch> <FilesMatch "\.combined\.css$"> Options +Includes AddOutputFilterByType INCLUDES text/css SetOutputFilter INCLUDES </FilesMatch> <IfModule mod_rewrite.c> RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L] </IfModule> 我知道这是可能的nginx,但我似乎无法得到正确的语法。 – 编辑 – 添加一些代码 我到目前为止唯一的一件事是: location ~* (.+)\.(?:\d+)\.(js|css)$ { ssi on; try_files $uri $1.$2; } 我正在寻找的是能够结合所有js和css文件到单个文件使用combined关键字与数字caching破坏: style.combined.100.css javascript.combined.100.js […]

虚拟主机configuration和mod_rewrite – 删除PHP扩展和添加正向斜杠

在我的生产服务器上,事情没有问题:在我的.htaccess文件中,PHP扩展删除和尾部的斜杠规则已经就位。 但在当地,这是行不通的(好,部分,无论如何)。 我正在运行Apache2虚拟主机的网站。 在这种情况下,我决定不使用.htaccess文件,而只是将规则添加到httpd-vhosts.conf文件中,我听说如果可能在服务器上,这是更好的方法。 虚拟主机正在工作,我用于我的网站的URL是这样的: devserver:9090 这是我的httpd-vhosts.conf文件: NameVirtualHost *:9090 # for stuff other than this site <VirtualHost *:9090> ServerAdmin admin@localhost DocumentRoot "/opt/lampstack/apache2/htdocs" ServerName localhost </VirtualHost> # for site in question <VirtualHost *:9090> ServerAdmin admin@localhost DocumentRoot "/opt/lampstack/apache2/htdocs/devserver" ServerName devserver <Directory "/opt/lampstack/apache2/htdocs/devserver"> Options Indexes FollowSymLinks Includes AllowOverride None Order allow,deny Allow from all </Directory> <IfModule rewrite_module> RewriteEngine […]

重写一个目录到另一个目录没有redirect

我有以下重写规则: RewriteRule ^support/(.*)$ /blog/support/$1 [R=301,NC,L] 但是,它只是一个简单的redirect。 我想要的/support显示/blog/support的内容,而无需更改/blog/support的URL。 我怎样才能做到这一点? 另外,以上只适用于/support有尾随斜线。

尽pipe重写规则匹配,404返回

我有一个重写规则,将所有请求发送到index.php : RewriteRule ^.*$ index.php [NC,L] (除了RewriteEngine On ,这就是.htaccess文件中的所有内容) 它工作,除非请求path以index/开头,在这种情况下,结果是404 Not Found 。 如果我将index.php的文件名更改为index2.php (并重写规则以匹配它),它将再次开始工作,所以当请求的path的第一个段等于目标文件的第一个段时 , 显然会有冲突 。 mod_rewrite日志包含这个(当请求/index/hello , 失败 ): add path info postfix: /path/to/index.php -> /path/to/index.php/hello strip per-dir prefix: /path/to/index.php/hello -> index.php/hello applying pattern '^.*$' to uri 'index.php/hello' rewrite 'index.php/hello' -> 'index.php' add per-dir prefix: index.php -> /path/to/index.php initial URL equal rewritten […]