Answer the question
In order to leave comments, you need to log in
301 redirect and circular addressing - how to solve the problem?
This is how it goes.
On the site, all pages are connected to index.php
parameters are passed via GET. That is www.site.ru/index.php?page=news .
The task was to make a CNC like www.site.ru/news/
I did this by adding the line to .htaccess:
RewriteRule ^(record|feedback|personal|licenses|work)/?$ index.php?page=$1 [L,NC]
But now you still need to make a 301 redirect from the old addresses to the new ones. That is, if I write www.site.ru/index.php?page=news in the address bar, then it redirects to www.site.ru/news/
BUT
Since www.site.ru/index.php?page=news and www.site.ru/news/is the same page, then it turns out that the page will be redirected to itself.
What needs to be done so that when requesting www.site.ru/index.php?page=news it goes to www.site.ru/news/
How can this be organized? Well, my head is spinning.
I didn’t find an answer to the question anywhere, and I hope for an adequate and intelligent Habr community.
Answer the question
In order to leave comments, you need to log in
Exclude with ! pages for which the redirect will not work, in this example I excluded the index.php file if you need a more complex url construction, then RewriteCond %{REQUEST_URI} !
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !index.php$
RewriteRule ^(record|feedback|personal|licenses|work)/?$ index.php?page=$1 [L,NC]
Nifiga did not understand.
Put a regular redirect on the old addresses, roughly speaking, if the user opens /index.php?page=news, then he will be redirected (with a change in the address in the address bar) to /news
Requests like /news are processed through the entry point (index.php), without redirect.
In what place here can there be a cyclic redirection?
can do everything from php? For example check $_SERVER['REQUEST_URI'] and do a redirect. or read here .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question