-2
重寫了我的網址。但是,我仍然可以訪問帶有問號和加號的重寫網址。上述需要重新查詢問號並在url中輸入等號
lovelakedistrict.com/lake-district-cottages/?cottages=2/
lovelakedistrict.com/lake-district-cottages/?cottages/2/
lovelakedistrict.com/lake-district-cottages/cottages/2/
三個網址是完全一樣的頁面,我想使他們重定向到正確的結構(最後URL)來阻止網頁複製到正確地重新寫。
Options +FollowSymlinks
Options +Indexes
RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^.#?\ ]+)\.php([#?][^\ ]*)?\ HTTP/
RewriteCond %1 !^include/
RewriteRule ^([^.]+)\.php$ /$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ $1.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
RewriteRule ^lake-district-cottages/cottages/([0-9]+) lake-district-cottages.php?cottages=$1
的htacccess規則從當工作分得很開我試試這個例子: http://www.lovelakedistrict.com/lake-district-cottages/?cottages=2/ 它指向 http://www.lovelakedistrict.com/ lake-cottage-cottages.php/cottages/2/ (增加了php的擴展) - 可以刪除嗎?感謝您的快速回復 – AJFMEDIA 2010-08-30 15:36:07
@ajfmedia:這可能是由於您使用這些規則的順序。請務必在那些導致內部重定向的規則之前放置那些導致外部重定向的規則。 – Gumbo 2010-08-30 15:46:00
它確定它現在排序:)非常感謝 – AJFMEDIA 2010-08-30 15:47:32