Question

I have a two Url rule

RewriteRule ^/user/strategies$ /user/index.html [NC,L]

RewriteRule ^/user/([a-zA-Z_0-9.]+)$ /user/index.html?username=$1  [NC,L]

You can see that they both contradict each other, what is the best possible way to solve this problem.

Was it helpful?

Solution

You can have these rules like this:

RewriteEngine On

RewriteRule ^user/strategies$ /user/index.html [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^user/([a-zA-Z_0-9.]+)$ /user/index.html?username=$1  [NC,L]
  • .htaccess is per directory directive and Apache strips the current directory path (thus leading slash) from RewriteRule URI pattern.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top