简体   繁体   中英

access to the php page only with one URL

I have a page called settings on my site and I want users to have access only with this url:

www.sitename.com/username/settings/

I have written this code in the .htaccess

RewriteRule ^(.*)/settings$ settings.php?UN=$1[NC,L] 

But also be accessed with the following addresses:

www.sitename.com/settings.php

or

www.sitename.com/settings.php?UN=username

You can use:

RewriteCond %{THE_REQUEST} /settings\.php [NC]
RewriteRule ^ - [F] 

RewriteRule ^(.*)/settings/?$ settings.php?UN=$1 [NC,L] 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM