我试图重写我的网址,以便删除php扩展并添加尾部斜杠。
我现在可以这样访问页面了.. lovelakedistrict.com/lake-district-cottages /
但我也可以通过这种方式访问它:
lovelakedistrict.com/lake-district-cottages.php
如何才能删除php扩展程序。这是我的htaccess
Options +FollowSymlinks
Options +Indexes
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php
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
答案 0 :(得分:1)
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /[^.#?\ ]+\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^([^.]+)\.php$ /$1 [R=301,L]