重写url导致重复页面
我尝试重写我的 url,以便删除 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
I have tried to rewrite my url so that it removes php extention and adds trailing slash.
I can access the page this way now..
lovelakedistrict.com/lake-district-cottages/
but i can also access it via this way:
lovelakedistrict.com/lake-district-cottages.php
how can I remove the php extention for good. this my 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)