我的网站上有一个名为“设置”的页面,我希望用户只能访问此网址:
www.sitename.com/username/settings/
我已经在.htaccess
中编写了这段代码RewriteRule ^(.*)/settings$ settings.php?UN=$1[NC,L]
但也可以通过以下地址访问:
www.sitename.com/settings.php
或
www.sitename.com/settings.php?UN=username
答案 0 :(得分:0)
您可以使用:
RewriteCond %{THE_REQUEST} /settings\.php [NC]
RewriteRule ^ - [F]
RewriteRule ^(.*)/settings/?$ settings.php?UN=$1 [NC,L]