A
A
Artur Khabirov2015-08-08 11:43:52
htaccess
Artur Khabirov, 2015-08-08 11:43:52

How to redirect the user to another page?

Made page redirection in htaccess. The file itself is in the news directory:
RewriteRule ^([0-9]+)/?$ index.php?id=$1 [L]
from news/?id=1 to news/1
Everything works fine. But, if you access the file at the old address, like news/?id=1, then in the address bar the page does not look like news/1, but news/?id=1 remains.
I don't know if I explained correctly or not. In short, I need that when entering a link like news/?id=1, the user is redirected to a link like news/1. Just now the news can be accessed via 2 links news/id=1 and news/1.
Thank you for your attention!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2015-08-08
@2fox

only by means of the language in which cms is written
htaccess ignores everything that is written after the ?
or
https://support.google.com/webmasters/answer/13906...

A
AntPask, 2015-08-08
@AntPask

for example try this
RewriteCond %{QUERY_STRING} ^id=([0-9]+)$
RewriteRule ^.* /news/%1/? [R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question