Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.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_Redirect - Fatal编程技术网

重定向到.htaccess中的index.php时出错

重定向到.htaccess中的index.php时出错,php,.htaccess,redirect,Php,.htaccess,Redirect,我正在通过.htaccess将我的域重定向到公用html文件夹中的子文件夹,如下所示: DirectoryIndex index.php RewriteEngine on RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$ RewriteCond %{REQUEST_URI} !^/mydomain.com/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME}

我正在通过.htaccess将我的域重定向到公用html文件夹中的子文件夹,如下所示:

DirectoryIndex index.php
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$ 
RewriteCond %{REQUEST_URI} !^/mydomain.com/ 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule ^(.*)$ /mydomain.com/$1 
RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$ 
RewriteRule ^(/)?$ mydomain.com/php [L]
在编写mydomain.com/index.php时,一切正常,但是如果我忽略index.php而只编写mydomain.co,我会得到404错误

我错过了什么


感谢您的帮助:-)

您是否已尝试从中删除尾部斜杠

RewriteCond %{REQUEST_URI} !^/mydomain.com/
成功

RewriteCond %{REQUEST_URI} !^/mydomain.com

^(.*)$
模式更改为
^(.+)$


或者,切换规则的顺序。

删除斜杠时,它会转到index.php,但会使我的url看起来像这样:mydomain.com/mydomain.com/