簡體   English   中英

htaccess 301重定向問題

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM