I have the following mod rewrite in my .htaccess and when I go to /commPortal.php it still ends up routing me to index2.php.
RewriteRule ^commportal/(.+)$ commPortal.php?data=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index2.php [QSA,L]
RewriteCond %{REQUEST_URI} .php [NC]
RewriteRule ^ index2.php [QSA,L]
This seems to be due to RewriteRule ^commportal/(.+)$ commPortal.php?data=$1 [L]
then getting picked up by:
RewriteCond %{REQUEST_URI} .php [NC]
RewriteRule ^ index2.php [QSA,L]
Is there any way to get the RewriteCond %{REQUEST_URI} .php [NC]
to see the commPortal.php rather than /commportal or even have it ignored if there was already a matching rewrite rule?
2
Answers
Change your last rule to this:
RewriteCond %{ENV:REDIRECT_STATUS} ^$
condition will be true only if there has been no internal rewrite before this rule thus executing this rule only no other rule has been fired before this.Another option to use
THE_REQUEST
variable that contains original request not the rewritten one:Could you please try following, based on your shown samples only. Please make sure to clear your browser cache before testing your URLs.