1
我使用這個的.htaccess這個裏面:.htacces沒有斜線重定向到具有斜線
DirectoryIndex index.php index.html
DirectorySlash On
Options -Indexes
Options +FollowSymlinks
RewriteEngine On
RewriteBase/
RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/(page1|page2|page3)$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
#Show every html,htm and xml as php
RewriteRule ^(.*)\.html$ $1.php [nc]
RewriteRule ^(.*)\.htm$ $1.php [nc]
RewriteRule ^(.*)\.xml$ $1.php [nc]
,但我沒有得到重定向到http://example.com/page1 - >http://example.com/page1/(和其他人第2頁第3頁和)。因爲我在本地測試我的網址將是 localhost/example/page1 並且應該重定向到 localhost/example/page1/ 確實有任何問題嗎?
仍然沒有工作,沒有我在的RewriteCond%的第一點{HTTP_HOST}^WWW \後SCAPE(+) $ [NC]? NE和NC代表什麼?也!-d都是遞歸目錄? fyi我在我的本地主機上測試 – Mik
你在瀏覽器中輸入'http:// domain.com/page1'嗎? – anubhava
我輸入http:// localhost/example/page1(和其他),並給我錯誤301 - 永久移動 – Mik