简体   繁体   English

如何使用.htaccess重定向我的网站

[英]How do I redirect my site using a .htaccess

How do I redirect my site using a .htaccess ? 如何使用.htaccess重定向我的网站?

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

to: 至:

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

It's not working in .htaccess : 它不适用于.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 : 使用Redirect指令,您无法将/index.php重定向到/index.php?page=search ,因为它将重定向到导致重定向循环错误的同一位置,您需要使用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. 如果您是不可见的重定向,请删除R标志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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