Answer the question
In order to leave comments, you need to log in
Redirect URL without changing URL in address bar?
Good afternoon, please tell me with one question, it is necessary to make a server redirect without changing the URL in the address bar, that is, what I mean
Now reviews open at:
/index.php?dispatch=discussion.view&thread_id=1
And in the address bar, exactly the same URL
It is necessary that the same URL be requested , but in the address bar of the browser there was a completely different look:
/reviews/1
For this, I wrote a rule in .htaccess, but for some reason it does not work, tell me what I did wrong?
RewriteEngine on
RewriteBase /
RewriteRule ^/index\.php\?dispatch=discussion\.view&thread_id=([\d]+)$ /reviews/$1/? [L,R=301]
Answer the question
In order to leave comments, you need to log in
The RewriteRule contains only the path to the file index.php
, and the parameters dispatch=discussion.view&thread_id=1
should be looked for in %{QUERY_STRING} or %{THE_REQUEST}.
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} (?:^|&)dispatch=discussion\.view(?:$|&)
RewriteCond %{QUERY_STRING} (?:^|&)thread_id=(\d+)(?:$|&)
RewriteRule ^index\.php$ /reviews/%1/? [R=301,L]
RewriteRule ^reviews/(\d+)/$ /index.php?dispatch=discussion.view&thread_id=$1 [L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question