.htaccess through error”;404未找到错误”;


.htaccess through error "404 Not Found error was encountered"

我在.htaccess文件中设置了如下的代码

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{HTTP_HOST} ^mydomain.in$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.in/$1 [R=301,L]
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

主页打开良好,但其他页面显示错误:

在此服务器上找不到请求的URL:目录/产品此外,在尝试使用ErrorDocument处理请求时,还遇到了404 Not Found错误

提前感谢

您的规则都出了问题。试试这个:

RewriteEngine On
# Redirect non-www to www
RewriteCond %{HTTP_HOST} ^mydomain.in$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.in/$1 [R=301,L]
# Do not redirect existing files/dirs
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# Redirect everything else to index.php
RewriteRule ^.*$ index.php [NC,L]