D
D
Darth Vader2016-10-24 12:54:21
htaccess
Darth Vader, 2016-10-24 12:54:21

How to strip part of URL using htaccess?

Hi all. I need to
configure htaccess for the site I need
to convert the https://site.com/category/odezhda format address to https://site.com/odezhda format .com/odezhda , but the site gives 404, but it needs to be shown to the user in the url site.com/odezhda, and the request went here site.com/category/odezhda
RewriteRule ^category/(.+)$ /$1 [R=301,L]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2016-10-24
@shambler81

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

In fact, you need to create the
first rule in the rewrite cond, select with brackets the part that you want to leave.
Accordingly, substituting this variable into the rule will not be $ 1 A% 1
Actually, all The
number is equal to the number of brackets, the first second third, and so on.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question