V
V
Vyacheslav Soldatov2014-12-02 08:36:38
MODX
Vyacheslav Soldatov, 2014-12-02 08:36:38

Why is my RewriteRule not working?

Good afternoon. It is necessary that links of the form

http://www.site.ru/company.html?name=bestcompany

replaced with links like
http://www.site.ru/company/bestcompany.html

Please advise where I went wrong. What he did:
Wrote accordingly:
RewriteRule ^company/([^/]*)\.html$ /company?name=$1 [L]

Worth Modx. .htaccess at the root, friendly urls work, full .htaccess code:
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

3 answer(s)
I
IceJOKER, 2014-12-02
@IceJOKER

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.

V
Vyacheslav Soldatov, 2014-12-02
@Syntaxys

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

Tried that, same result.

T
toxa82, 2014-12-02
@toxa82

Try like this

RewriteRule ^company/(.*?)\.html$  /company.html?name=$1 [L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question