PinkTurtle
PinkTurtle

Reputation: 7041

Regexp RewriteCond doesn't match

I have these lines in a .htaccess file :

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} ^(.*/|)(en|de|fr)(/.*|)$ [NC]
#RewriteCond %1%3.php -f
RewriteRule ^(.*/|)(en|de|fr)(/.*?)/?$ $1$3.php?lang=$2 [NC,QSA,L]

The third (commented) line doesn't work. Everything else is fine though. Can anyone point me out to what is wrong here ? The RewriteRule works very well, ie the file $1$3.php exists and is correctly displayed.

Thank you for any help.

Upvotes: 1

Views: 145

Answers (1)

joar
joar

Reputation: 15947

This is just a qualified guess

The regular expression values does not exist on the third line - You can not use values catched in a RewriteCond (e.g. $1$3, or as written in your example: %1%3) in another RewriteCond. You can only use the values ($n) in the RewriteRule.

On the other hand, I can't see why you would need the third line. You're saying that the rewrite should only be applied if $1$3.php exists, do you have any other rewrite rules that you are activated if $1$3.php file doesn't exist?

Upvotes: 1

Related Questions