M
M
mokrosoft2016-04-23 14:54:56
htaccess
mokrosoft, 2016-04-23 14:54:56

How to write a redirect without duplicating a page?

Hello, there is a page on the site:
site.com/page1 - you need:
1. For this page to be displayed as a root page,
2. So that when I type site.com/page1 in the browser, there is a 301 redirect to the root page (well, it is also displayed )
the first redirect works fine:
RewriteRule ^$ page1 [L]
If you write after that:
RewriteRule ^page1$ / [R=301,L]
Then an error occurs.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
adminstock, 2016-05-02
@adminstock

the first redirect works fine:
RewriteRule ^$ page1 [L]
If you write after that:
RewriteRule ^page1$ / [R=301,L]

Those. do you redirect from main to page1 first , then from page1 to main, and then from main to page1 , and then from page1 to main, and then from main to page1 , and then from page1 to main?... Error: Exceeded number of redirects, contact the administrator for more information :-)
Perhaps the problem is a typo, if the pages are different, then there should not be any problems:
# с главной на /page22222
RewriteRule ^$ page22222 [R=301,L]
# с /page11111 на главную
RewriteRule ^page11111$ / [R=301,L]

or with slashes:
RewriteRule ^/$ page22222 [R=301,L]
RewriteRule ^/page11111$ / [R=301,L]

from /page11111 you can immediately redirect to /page22222 :
RewriteRule ^/page11111$ page22222 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question