1

无法弄清楚为什么此重定向不起作用。这不是将页面重定向到目录的正确方法(见最后一行)吗?

RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.|$) [NC]
RewriteRule ^ www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.html [NC,L]
AddDefaultCharset UTF-8
ErrorDocument 404 /404.html
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript
ExpiresActive On
ExpiresDefault "access plus 1 minute"
Redirect 301 /folder/name/main.html‎ /a-nother-folder
4

1 回答 1

1

不要混合 mod_rewrite 和 mod_alias。将您的代码更改为:

AddDefaultCharset UTF-8
ErrorDocument 404 /404.html
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript
ExpiresActive On
ExpiresDefault "access plus 1 minute"

RewriteEngine On

RewriteRule ^folder/name/main\.html‎$ /a-nother-folder [L,NC,R=301]

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.html [NC,L]

还可以尝试在不同的浏览器中进行测试。

于 2013-09-17T16:54:36.327 回答