重写了我的网址。但是我仍然可以使用问号和加号访问重写的 url。
lovelakedistrict.com/lake-district-cottages/?cottages=2/
lovelakedistrict.com/lake-district-cottages/?cottages/2/
lovelakedistrict.com/lake-district-cottages/cottages/2/
上面的三个 url 是完全相同的页面,我想正确地重新编写它们,以便它们重定向到正确的结构(最后一个 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