M
M
Maxim Vyaznikov2019-11-04 19:23:55
Apache HTTP Server
Maxim Vyaznikov, 2019-11-04 19:23:55

Can you help me redirect to .htaccess?

There is a site domain.ru, all content was in the folder domain.ru/5/domain.ru/
I.e. url like domain.ru/5/domain.ru/123.html, domain.ru/5/domain.ru/dir1/456.html
Now everything has been moved to the root, I'm trying to create .htaccess in folder 5

RewriteEngine on
RewriteRule (.*) http://domain.ru/$1 [NC,L,R=301]

Redirects to domain.ru/domain.ru/request
Well, here it seems to be logical, this is for testing.
Then I change (.*) to ^\/domain\.ru\/(.*)$, there is no redirection, ^\/5\/domain\.ru\/(.*)$, also not, and a bunch of other options , now I can’t list everything from memory.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
W
wisgest, 2019-11-04
@wisgest

Perhaps not enough RewriteBase.
But I would do this:
Redirect 301 /5/domain.ru/ /

D
dodo512, 2019-11-04
@dodo512

If the file is in folder
5./5/.htaccess

RewriteEngine on
RewriteRule ^domain\.ru/(.*)$ http://domain.ru/$1 [L,R=301]

Or create .htaccess not in folder 5, but a level below.
/5/domain.ru/.htaccess
RewriteEngine on
RewriteRule (.*) http://domain.ru/$1 [L,R=301]

V
Viktor Taran, 2019-11-05
@shambler81

Place at the very beginning of the file (this matters)

RewriteBase /
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.ru$
RewriteRule ^5/domain\.ru/(.+)$ http://domain.ru/$1 [L,R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question