Вопрос

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.

Это было полезно?

Решение

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.
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top