【发布时间】:2011-11-12 08:33:20
【问题描述】:
目前我正在使用带有 lightspeed 服务器的主机。托管说mod_rewrite 已启用,但我无法让我的脚本在那里工作。每当我尝试访问该 URL 时,它都会返回 404 - not found 页面。
我将相同的代码放在另一台运行 Apache 的服务器上。它在那里工作。所以我猜,这是.htaccess 和mod_rewrite 的问题。
但是托管支持仍然坚持告诉我他们的 mod_rewrite 已打开,所以我想知道如何检查它是否实际启用。
我尝试与phpinfo() 联系,但没有运气,我在那里找不到mod_rewrite,是因为他们使用的是lightspeed吗?
有什么方法可以检查吗?请帮帮我。谢谢。
仅供参考:我的.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 tutorial for beginnershelponnet.com/2021/04/15/htaccess-tutorial-for-beginers,希望对您有所帮助。 -
另请阅读
How to check if htaccess is workinghelponnet.com/2021/05/14/…
标签: php .htaccess mod-rewrite url-rewriting lightspeed