简体   繁体   中英

How do I redirect my site using a .htaccess

How do I redirect my site using a .htaccess ?

http://www.domain.com/index.php

to:

http://www.domain.com/index.php?page=search

It's not working in .htaccess :

redirect 301 /index.php http://domain.com/index.php?page=search

With Redirect directive you can not redirect /index.php to /index.php?page=search as it will redirect to the same location causing a Redirect loop error, You need to use mod-rewrite :

Try :

RewriteEngine on

RewriteCond %{QUERY_STRING} ^$
RewriteRule ^index\.php$ /index.php?page=search [NC,L,R]

Remove the R flag if you an invisible redirection.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM