Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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
Php codeigniter重写URL不起作用_Php_Apache_.htaccess_Codeigniter_Mod Rewrite - Fatal编程技术网

Php codeigniter重写URL不起作用

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/

在过去,我让它工作没有任何问题,但由于某种原因,在我的新服务器上,我就是不能让它工作

我的应用程序根目录中有以下.htaccess文件

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]