Php codeigniter重写URL不起作用
在过去,我让它工作没有任何问题,但由于某种原因,在我的新服务器上,我就是不能让它工作 我的应用程序根目录中有以下.htaccess文件Php codeigniter重写URL不起作用,php,apache,.htaccess,codeigniter,mod-rewrite,Php,Apache,.htaccess,Codeigniter,Mod Rewrite,在过去,我让它工作没有任何问题,但由于某种原因,在我的新服务器上,我就是不能让它工作 我的应用程序根目录中有以下.htaccess文件 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] 我还启用了mod_rewrite,并用php_info()确认了这一点 我的网站位于/var/www/html/
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
我还启用了mod_rewrite,并用php_info()确认了这一点
我的网站位于/var/www/html/test
尽管启用了mod_rewrite,但它是否可能不起作用?如果是,我如何测试它?在某些服务器实现中,您需要将其包装在
标记中
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
还值得检查以确保.htaccess
文件没有被另一个.htaccess
文件覆盖
一种测试.htaccess是否正常工作的简单方法
只需将以下内容放入.htaccess
文件:
deny from All
这样做的目的是拒绝所有人访问您的站点。如果您在尝试访问网站时收到403禁止-将包括
.htaccess
文件。如果没有-请参见上文。我在codeigniter设置中使用此选项
RewriteEngine on
# prevent these directories from hitting CI
RewriteCond $1 !^(index\.php|images|assets|robots\.txt|crossdomain\.xml)
# route everything else to the index.php
RewriteRule ^/(.*)$ /index.php/$1 [QSA]
(我的设置是在.conf的virtualhost中完成的,而不是在.htaccess中完成的,尽管它们通常是相同的配置)
RewriteEngine on
# prevent these directories from hitting CI
RewriteCond $1 !^(index\.php|images|assets|robots\.txt|crossdomain\.xml)
# route everything else to the index.php
RewriteRule ^/(.*)$ /index.php/$1 [QSA]