[英]htaccess 301 redirect issues
问题:我刚刚对公司网站进行了重大更新,并尝试使某些重定向生效。 现在如果我有
Redirect 301 folder1/oldFile1.html http://www.mysite.com/newFolder1/newFolder2/newFile.html
当您进入新设置时,我会收到404
http://www.mysite.com/newFolder1/newFolder2/newFile.htmloldFile.html
任何想法是什么原因造成的?
注意:这似乎只发生在从1文件夹结构移动到2文件夹结构的文件中。
RewriteOptions inherit
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^mysite.com [nc]
rewriterule ^(.*)$ http://www.mysite.com/$1 [r=301,nc]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html?\ HTTP/
RewriteRule ^(.*)index\.html?$ http://www.mysite.com/$1 [R=301,L]
不要将mod_rewrite
规则与mod_alias
规则混合使用。
使用此代替:
RewriteOptions inherit
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{http_host} ^mysite\.com$ [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,NC,L]
RewriteCond %{THE_REQUEST} \s/.*index\.html?\ HTTP/
RewriteRule ^(.*)index\.html?$ http://www.mysite.com/$1 [R=301,L]
RewriteRule ^folder1/oldFile1\.html$ /newFolder1/newFolder2/newFile.html? [R=301,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.