.htaaccess question

Is there a nicer / shorter way to write the following rules?

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule en/([a-zA-Z]+) en/$1.php [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ([a-zA-Z]+) $1.php [L]

I haven’t tested it, but seems like this should do the trick:

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ((?:en/)?[a-zA-Z]+) $1.php [L]

“en/” may optionally be part of the pattern, and if it is, then it’s also included in the replacement.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.