Answer the question
In order to leave comments, you need to log in
Why doesn't the regular expression for mod_rewrite work in .htaccess?
There are some pages with addresses like /dir1/dir2/page_name_123.html, they should be redirected using mod_rewrite to
/dir1/dir2/page_name.html having the extension "html".
The code turned out offhand like this (cut out irrelevant):
# ...
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
# ...
RewriteCond %{REQUEST_URI} ^/dir1/dir2/(.+)_[0-9]{1,3}\.html$
RewriteRule /dir1/dir2/(.+)_[0-9]{1,3}\.html$ http://sitename.ru/dir1/dir2/$1.html [L,R=301]
Answer the question
In order to leave comments, you need to log in
It worked for me without the 1st slash in the rewriterule:RewriteRule dir1/dir2/(.+)_[0-9]{1,3}\.html$
Thanks, it worked!
However, what is the reason for this, I did not understand. I will dig the documentation further, most importantly, the urgent task is solved.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question