V
V
Vladimir Lugovkin2015-11-08 21:32:41
Apache HTTP Server
Vladimir Lugovkin, 2015-11-08 21:32:41

Problems with .htaccess: incorrect directory handling?

Tell me, what is the problem that my rules do not work?
It is necessary that the subdomain works with the subdirectory of the site as with the root one: going to the address sms-rassilka-barnaul.sitename.ru should open the directory /cities/barnaul/*
And so for many cities.
Previously, it was prescribed forcibly:

RewriteCond %{HTTP_HOST} ^(www\.)?sms-rassilka-barnaul\.sitename\.ru$ [NC]
RewriteCond %{REQUEST_URI} !^/cities/barnaul/ [NC]
RewriteRule ^(.*)$ /cities/barnaul/$1 [L,QSA]

write according to the pattern
RewriteCond %{HTTP_HOST} sms-rassilka-([a-z]+)\.sitename\.ru$ [NC]
RewriteCond %{REQUEST_URI} !^/cities/%1/ [NC]
RewriteRule ^(.*)$ /cities/%1/$1 [L,QSA]

and throws out a 500 Internal Server Error. And for some reason, it is the second line that is not processed, everything is transferred to the third.
PS Site on Bitrix, MB is it somehow corrected?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Lugovkin, 2015-11-09
@darkvovich

Decided! The correct code is this:

RewriteCond %{HTTP_HOST} ^sms-rassilka-([a-z]+)\.sitename\.ru [NC]
RewriteRule ^((?!cities/.*).*)$ /cities/%1/$1 [L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question