目前我正在使用安装了Lightspeed服务器的主机。主机商称已启用mod_rewrite
,但我无法在该服务器上运行我的脚本。每当我尝试访问URL时,都会返回404-未找到页面。
我将相同的代码放在另一台运行Apache的服务器上。它在那里工作。所以我猜测这是.htaccess
和mod_rewrite
的问题。
但是主机支持仍然坚称他们的mod_rewrite已经启用,所以我想知道如何检查它是否真正启用。
我尝试使用phpinfo()
来检查,但没有成功,在那里我找不到mod_rewrite
,这是因为他们正在使用Lightspeed
吗?
有没有办法检查?请帮帮我。谢谢。
FYI: 我的.htaccess
代码是:
Options -Indexes
<IfModule mod_rewrite.c>
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
</IfModule>
我也试过这样
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
但是结果相同。
mod-rewrite
是否启用的最简单方法是将一些随机文本粘贴到您的htaccess文件中,然后访问您的网站,如果该模块已启用,则会出现内部服务器错误。这是我几个月前写的一个快速的“htaccess入门教程”,https://helponnet.com/2021/04/15/htaccess-tutorial-for-beginers/ 希望您会发现它有用。 - Amit Verma