I
I
Ivan Ilyasov2017-05-24 17:19:15
htaccess
Ivan Ilyasov, 2017-05-24 17:19:15

How to redirect from a page without GET parameters to a page with GET parameters?

In this case, it is necessary that the slash is taken into account, that is, the task is:
Redirect from and from to Did this, but there is a cyclic redirection:http://site.ru/pagehttp://site.ru/page/http://site.ru/page?process=view

RewriteCond %{REQUEST_URI} ^/(page|page/)$
RewriteRule .+ http://site.ru/page?process=view [R=301,L]

That is, this garbage: RewriteCond %{REQUEST_URI} ^/(page|page/)$it does not perceive the end of the line on pageor page/and for some reason considers that the page with the address ending with a get-request page\?process=viewfits the regular expression page$, which is strange.
Update:
The solution to the question is written in the comments in the answer below.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Taran, 2017-05-25
@IvanIlyasov

Don't forget to mark as solved.
well, don't forget to escape special characters in the regular season!!!
It was

RewriteCond %{REQUEST_URI} ^/(page|page/)$
RewriteRule .+ http://site.ru/page?process=view [R=301,L]

It became
RewriteCond %{REQUEST_URI} ^/(page|page/)$
RewriteRule .+ http://site.ru/page\?process=view [R=301,L]

S
Salim_Gareev, 2017-05-24
@Salim_Gareev

You need to work not with %{REQUEST_URI} but with %{QUERY_STRING}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question