Answer the question
In order to leave comments, you need to log in
How to strip part of URL from URL using htaccess?
Greetings.
There are pages like site.ru/cat1/cat2/art.htm?fb_comment_id=12345&start=2 And the numbers in the segment id=12345 are always different.
I don’t understand how to cut out the fb_comment_id=123456789& part using htaccess to get pages like site.ru/cat1/cat2/article.html?start=2
I tried this:
RewriteCond %{QUERY_STRING} ^fb_comment_id= [NC]
RewriteRule (.*) $1? [R=301,L]
Answer the question
In order to leave comments, you need to log in
if you need to list numbers
If you need to transfer some of the elements from the conda to the steering wheel
Use brackets to select (patern1)(patern2)
a in the steering wheel instead of $1 $2 use %1 %2 (bucks will remain for the steering wheel itself)
Example:
#RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
# Проверяем, содержит ли домен www (в начале URL).
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# 301 --- http://site.ru/cat1/cat2/art.htm?fb_comment_id=12345&start=2 => http://site.ru/cat1/cat2/article.html?start=2
RewriteCond %{QUERY_STRING} (^|&)fb_comment_id\=12345($|&)
RewriteCond %{QUERY_STRING} (^|&)start\=2 ($|&)
RewriteRule ^cat1/cat2/art\.htm$ /cat1/cat2/article.html?start=2 [L,R=301]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question