Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.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重写规则与index.php异常_Php_.htaccess_Mod Rewrite - Fatal编程技术网

Htaccess重写规则与index.php异常

Htaccess重写规则与index.php异常,php,.htaccess,mod-rewrite,Php,.htaccess,Mod Rewrite,我们有一个基于URL字符串重定向的网站 Allow from all RewriteEngine on RewriteRule ^(.*)$ redir.php?j=$1 [R=301,L] 其中redir.php是实际的URL。这个htaccess文件工作得很好,但是,我想对index.php或根URL做一个例外。我们如何修改上述htaccess以添加异常而不干扰现有功能 类似的问题:-但是我们不想要子域。这是根域。我知道我们需要rewriteCond语句,但我们不想干扰现有功能。您可以尝试

我们有一个基于URL字符串重定向的网站

Allow from all
RewriteEngine on
RewriteRule ^(.*)$ redir.php?j=$1 [R=301,L]
其中redir.php是实际的URL。这个htaccess文件工作得很好,但是,我想对index.php或根URL做一个例外。我们如何修改上述htaccess以添加异常而不干扰现有功能


类似的问题:-但是我们不想要子域。这是根域。我知道我们需要rewriteCond语句,但我们不想干扰现有功能。

您可以尝试遵循重定向规则

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^$ http://example.com/index.php [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ redir.php?j=$1 [R=301,L]