Answer the question
In order to leave comments, you need to log in
How can I change htaccess so that urls beyond a certain slash are simply cut off?
Good day.
There is a site on Bitrix and the directory structure has recently changed + the writing of urls was transferred to CNC. Accordingly, you need to set up a redirect from old indexed pages to new URLs.
Previously, the structure was as follows:
Catalog section - example.com/catalog/1234
Product card - example.com/catalog/1234/9876
Now the structure is this:
Catalog section - example.com/section/subsection/subsection_double_name (I know that is not very successful, but so far)
Product card - example.com/section/subsection/item_name The
redirect is now carried out through htaccess
Approximately in this form:
redirect /catalog/1234/9876/ http://example.com/section/subsection/item_name
... and so all the product cards available at the time of the transition on the site and after them the sections of the catalog separately:
redirect
/catalog/1234 http://example.com/section/subsection/subsection_double_name
a product card that has already been removed from the site, for example, having ID 9999 and once located at: example.com/catalog/1234/9999,
then as a result, the redirect works to a URL of this type:
example.com/section/subsection/subsection_double_name /9999
Question - how can I tell in htaccess that urls beyond a certain slash are simply cut off? So that in the example above, the redirect to the section eventually worked out.
Answer the question
In order to leave comments, you need to log in
The apache documentation ( http://httpd.apache.org/docs/2.2/mod/mod_alias.html#Redirect ) describes this case in detail:
Then any request beginning with URL-path will return a redirect request to the client at the location of the target URL. Additional path information beyond the matched URL-path will be appended to the target URL.
Example:
Redirect /service http://foo2.example.com/service
If the client requests http://example.com/service/foo.txt, it will be told to access http://foo2.example.com/ service/foo.txt instead. Only complete path segments are matched, so the above example would not match a request for http://example.com/servicefoo.txt. For more complex matching using regular expressions, see the RedirectMatch directive.
Arrange the redirects in the correct order, and you don't need to cut anything.
In your example, redirect the catalog first, then the product.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question