Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess Htaccess重定向,重定向循环_.htaccess_Url_Url Redirection - Fatal编程技术网

.htaccess Htaccess重定向,重定向循环

.htaccess Htaccess重定向,重定向循环,.htaccess,url,url-redirection,.htaccess,Url,Url Redirection,我想将mysite.com/index.php重定向到mysite.com/index.php?id\u category=12&controller=category 这是我的htaccess文件 但它不起作用。Chrome说:这个网页有一个重定向循环 Options +FollowSymLinks +SymLinksIfOwnerMatch RewriteEngine On RewriteBase / RewriteRule index\.php http://mysite.com/in

我想将
mysite.com/index.php
重定向到
mysite.com/index.php?id\u category=12&controller=category

这是我的htaccess文件

但它不起作用。Chrome说:
这个网页有一个重定向循环

Options +FollowSymLinks +SymLinksIfOwnerMatch

RewriteEngine On
RewriteBase /

RewriteRule index\.php http://mysite.com/index.php?id_category=12&controller=category

可能您应该更改使用另一个文件名,而不是index.php作为destiny。但你可以试试:

RewriteRule index.php index.php?id_category=12&controller=category

这应该可以:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/index.php$
RewriteCond %{QUERY_STRING} ^$
RewriteRule (.*) http://www.mywebsite.com/index.php?foo=bar [R=301,L]

第一个条件检查URI是否等于
index.php
,第二个条件检查GET值是否为空。这两个条件之间的AND在这里是隐含的。

为什么
mysite.com/index.php
?您没有在输入的URL中传递参数,因此无需输入
index.php
mysite.com
就足够了。你确定这就是你想要的吗?