.htaccess 如何使用htaccess将页面重定向到文件夹?
无法找出此重定向不起作用的原因。这不是将页面重定向到目录的正确方法吗(参见最后一行).htaccess 如何使用htaccess将页面重定向到文件夹?,.htaccess,.htaccess,无法找出此重定向不起作用的原因。这不是将页面重定向到目录的正确方法吗(参见最后一行) 不要混合使用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/javascr
不要混合使用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]
也可以尝试在其他浏览器中进行测试。不要将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]
也可以尝试在其他浏览器中进行测试。尝试使用完全限定的URL作为目标URL(即
http://example.com/a-nother-folder
)<代码>重定向对相对路径不起作用。谢谢Jason,成功了!尝试使用完全限定的URL作为目标URL(即http://example.com/a-nother-folder
)<代码>重定向对相对路径不起作用。谢谢Jason,成功了!感谢您指出“不要混合使用mod_rewrite和mod_alias”感谢您指出“不要混合使用mod_rewrite和mod_alias”