C
C
choodo2015-07-14 22:35:54
Apache HTTP Server
choodo, 2015-07-14 22:35:54

How to write Redirect rules in .htaccess for files in nested directories?

Situation: there was an old site. Approximately 50 links to his various pages "settled" on the forums. Launched a new site with a new name and a different structure. For the old domain name, a one-page site was created - a stub.
Task: is it possible to write such redirects in the root .htaccess of the old site so that without creating a real directory structure, redirect requests to the old addresses to the necessary pages of the new site?
Example:
Actually, what doesn't work: the forum has a link like site.ru/ru/products/e1-access/ and clicks on it. It is necessary to navigate through it to redirect to site2.ru/catalog/226/
Tried to create a line in the root .htaccess

Redirect 301 /ru/products/e1-access/ http://site2.ru/catalog/226/
, but that's not how the redirect works. You have to create the /catalog/226/ directory and place your .htaccess with the line
Redirect 301 /ru/products/e1-access/  http://site2.ru/catalog/226/
.
How to correctly describe the rules in a single root .htaccess for my case?
ps the site was abandoned long before my arrival.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ShamblerR, 2015-07-15
@ShamblerR

Well, for starters,
Redirect 301 doesn't work with regular expressions.
Solution 1: read here klondike-studio.ru/blog/vse_pro_hosting/301-redire...
I have described the main snippets for SEO redirects here. Your case is below.
Solution 2: lazy! https://donatstudios.com/RewriteRule_Generator

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question