I'm looking for a way to disable access to file, if not accessed through slug. for example, I have /members.php?page=login
. I want to change it, by forcing the user access /login
(redirect the long url into a short slug) and prevent direct access from the long url.
When I try to do something like:
RewriteRule ^members.php?page=login login [L,R=301]
RewriteRule ^login members.php?page=login [L]
It turns into an infinite loop (as firefox says: "Firefox has detected that the server is redirecting the request for this address in a way that will never complete.").
I've enabled the "options" at the beginning of file ( Options +FollowSymLinks -MultiViews
)
How can I make it right?
Thanks.
try this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^login$ index.php?page=login [L]
You can use the following :
RewriteEngine on
# externally redirect "/members.php?page=login" to "/login"
RewriteCond %{THE_REQUEST} /members\.php\?page=login [NC]
RewriteRule ^ /login [L,R]
#rewrite "/login" back to "/members.php?page=login"
RewriteRule ^login members.php?page=login [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.