2013-05-08 92 views
0

我創建了一個.htaccess文件,其中包含一個站點的重定向,該站點是較大WordPress多站點安裝的一部分。刪除WP多站點.htaccess文件中的尾部斜槓

中的.htaccess內容與此(必要的開始,因爲同.httacess文件必須被用於多個站點:

RewriteCond %{HTTP_HOST} ^mydomain.com [nc] 

然後包含一系列重寫的,就像這樣:

RewriteRule ^about-my-site$ about [R=301,NC,L] 

如果我訪問mydomain.com/about-my-site,我被正確地重定向到mydomain.com/about 但是,如果我訪問mydomain.com/about-my-site/(請注意尾部斜線),我會收到「頁面未找到」錯誤。

回答

1

你重寫規則更改爲

RewriteRule ^about-my-site/?$ about [R=301,NC,L] 
+0

暫時更改爲[R,NC]並檢查您的重定向位置。 – 2013-05-08 20:39:31

+0

你原來的建議奏效。對困惑感到抱歉。非常感謝你的幫助。 – jonzal 2013-05-08 20:52:06

+0

我很高興它有幫助。 – 2013-05-08 21:11:58

1

這些規則你的WordPress規則之前應該去,確保改寫爲上,並設置/重寫基地 -

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteCond %{HTTP_HOST} mydomain.com [NC] 
RewriteRule ^about-my-site/? about [R=301,NC,L] 
</IfModule> 

測試在這裏:http://htaccess.madewithlove.be/

input url 
http://mydomain.com/about-my-site/ 

output url 
http://mydomain.com/about 

debugging info 
1 RewriteEngine On 
2 RewriteBase/
3 RewriteCond %{HTTP_HOST} mydomain.com [NC]  This condition was met 
4 RewriteRule ^about-my-site/? about [R=301,NC,L] This rule was met, the new url is http://mydomain.com/about 
Test are stopped, because of the R in your RewriteRule options. A redirect will be made with status code 301 
+0

+1分享測試網站。我曾經測試過我的本地Apache。謝謝。 – 2013-05-08 21:14:31