简体   繁体   English

htaccess 301重定向问题

[英]htaccess 301 redirect issues

Problem: I just did a major update to my companies website and trying to get some redirects to work. 问题:我刚刚对公司网站进行了重大更新,并尝试使某些重定向生效。 Right now if I have 现在如果我有

Redirect 301 folder1/oldFile1.html http://www.mysite.com/newFolder1/newFolder2/newFile.html

and when you got to the new set up, I get this instead with a 404 当您进入新设置时,我会收到404

http://www.mysite.com/newFolder1/newFolder2/newFile.htmloldFile.html

any ideas what is causing this? 任何想法是什么原因造成的?

Note: this only appears to happen to files that are moving from a 1 folder structure to a 2 folder structure. 注意:这似乎只发生在从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]

Don't mix mod_rewrite rules with mod_alias rules. 不要将mod_rewrite规则与mod_alias规则混合使用。

Use this instead: 使用此代替:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM