I tried to redirect but not working even I put the correct code from take it from web.
Redirect /index.php?page=8 /?page=8
I tried to redirect but not working even I put the correct code from take it from web.
Redirect /index.php?page=8 /?page=8
2
Answers
Your htaccess code should be.
The mod_alias
Redirect
directive does not match against the query string, so the above directive will never match, so does nothing.To remove the
index.php
(directory index) from the visible URL, you would need to use mod_rewrite at the top of your.htaccess
file. For example:The above will redirect a URL of the form
/index.php?page=8
to/?page=8
. Any query string present on the initial request is simply passed through to the target/substitution unaltered.The condition that checks against the
REDIRECT_STATUS
env var ensures we don’t get a redirect loop caused by mod_dir (or the Laravel front-controller) rewriting the request toindex.php
.Clear your browser cache and test first with a 302 (temporary) redirect.
However, if you did only want to redirect the specific URL
/index.php?page=8
(as stated in the question) to/?page=8
then you should write the rule like the following instead: