i'm using mod_rewrite and there's some jquery/AJAX that loads in the content always using the new url: /user/register/
RewriteRule ^user/register/?$ register.php [NC,L,QSA]
but i also want to deny [or redirect] letting someone goto the register.php file directly. i tried to add this below, but it broke the top rule from working.
RewriteRule ^register\.php$ - [F,L]
how do i do both in the rules?
RewriteRule ^register\.php$ - [F,L]
This isn't going to work by itself, because your other rule rewrites the URI to register.php
, then when the rewrite engine loops, this rule gets applied and ultimately a 403 is returned. You need to check against the actual request itself:
RewriteCond %{THE_REQUEST} /register\.php($|\ |\?)
RewriteRule ^ - [F,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.