Answer the question
In order to leave comments, you need to log in
Why is my RewriteRule not working?
Good afternoon. It is necessary that links of the form
http://www.site.ru/company.html?name=bestcompany
http://www.site.ru/company/bestcompany.html
RewriteRule ^company/([^/]*)\.html$ /company?name=$1 [L]
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.site\.ru [NC]
RewriteRule (.*) http://www.site.ru/$1 [R=301,L]
# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
RewriteRule ^company/([^/]*)\.html$ /company.html?name=$1 [L]
Answer the question
In order to leave comments, you need to log in
You see above there is a rule that sends all requests to index.php and there is an L modifier, that is, if a match is found, then this will be the last rule.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.site\.ru [NC]
RewriteRule (.*) http://www.site.ru/$1 [R=301,L,NE]
RewriteRule ^company/([^/]*)\.html$ /company.html?name=$1 [L]
# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question