A
A
Anumik2016-08-31 08:07:13
Apache HTTP Server
Anumik, 2016-08-31 08:07:13

How to fix mod_rewrite?

Good day
A rule is configured in .htaccess,

RewriteEngine on
  RewriteCond %{REQUEST_URI} (^.)+
  RewriteCond %{HTTP_COOKIE} CITY=([^;]+) [NC]
  RewriteRule ^(.*)$ /%1/$1 [L,R=301]

but it didn't work out what I needed. I need URLs like site.com/%1 or site.com/%1/company/ to display site.com or site.com/company/ and now I'm getting a sitemap or an error.
The address is formed correctly, i.e. in the line I get the correct site.ru/irk/ or site.ru/irk/company/

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2016-08-31
@Anumik

%1 is part of the url ? or is it a variable from rewritecond ?
if it's just a url then somewhere like that ?

RewriteCond %{REQUEST_URI} ^(.*)/dir1/(.*)$ 
# если строка содержит /dir1/ 
RewriteRule ^(.*)$ %1/dir2/%2 [R=301,L] 
#Перенаправить все урлы с начинающиеся с dir1 на dir2 с сохранением дальнейшей структуры URL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question