Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 重写条件和规则,某些页面除外_Apache - Fatal编程技术网

Apache 重写条件和规则,某些页面除外

Apache 重写条件和规则,某些页面除外,apache,Apache,你好,我想在apache2上使用重定向模块 如果请求“test.net/xxx”,则重定向到“test.test..net/xxx” 但index.html页面除外 例如,如果请求“test.net/index.html”,则没有重定向 我编写了apache2 conf文件,如下所示 RewriteEngine on RewriteCond %{HTTP_HOST} ^test\.net [NC] RewriteRule ^http://test\.net/([^index\.html]) ht

你好,我想在apache2上使用重定向模块

如果请求“test.net/xxx”,则重定向到“test.test..net/xxx”

但index.html页面除外

例如,如果请求“test.net/index.html”,则没有重定向

我编写了apache2 conf文件,如下所示

RewriteEngine on
RewriteCond %{HTTP_HOST} ^test\.net [NC]
RewriteRule ^http://test\.net/([^index\.html]) http://test.test.net/$1 [R=301,L]
但是不起作用

如何编辑以上句子?请告诉我


谢谢

您添加了一个条件,以确保仅在不满足异常的情况下应用该规则,并修复实际的重写规则:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^test\.net$ [NC]
RewriteCond %{REQUEST_URI} !^/index\.html$
RewriteRule ^/?(.*)$ http://test.test.net/$1 [R=301]
该规则将适用于http服务器主机配置,但也适用于动态配置文件(“.htaccess”)


如果您收到具有上述规则的http状态500(“内部服务器错误”),那么很可能您操作的是非常旧版本的apachE http服务器。然后,错误日志文件将指出未知标志
[END]
。在这种情况下,将其替换为旧的
[L]
标志

谢谢你的回答,我应用你的建议,然后“test.net/xxx”到“test.test..net/xxx”是有效的,但是“test.net/index.html”被重定向到“test.test.net/index.html”并且我需要更多的帮助,谢谢。我向你道歉,我在第二个条件中做了一个小的修改,希望事情现在能如预期的那样工作。
%{REQUEST_URI}
显然包含一个绝对路径,因此带前导斜杠的字符串。。。