Codeigniter htaccess不工作 [英] Codeigniter htaccess not working
本文介绍了Codeigniter htaccess不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的网站上使用这个htaccess文件来删除index.php。
RewriteEngine on
RewriteCond $ 1 !^(index\.php)
RewriteCond%{REQUEST_FILENAME}!-f
RewriteCond%{REQUEST_FILENAME}!-d
RewriteRule ^(。*)$ index.php / $ 1 [ L,QSA]
但是此文件不工作。在Apache module.Version中启用重写codeigniter使用的是2.0.1。
解决方案
我测试了这个没有codeigniter,
$ b
我在htdocs下创建一个名为demo的文件夹。我把.htaccess与您的内容+额外的行(RewriteBase):
RewriteEngine on
RewriteBase / demo /
#RewriteCond $ 1!^(index\.php)
RewriteCond%{REQUEST_FILENAME}!-f
RewriteCond%{REQUEST_FILENAME}!-d
RewriteRule ^ )$ index.php / $ 1 [L,QSA]
/ p>
<?php
echo $ _SERVER ['PATH_INFO'];
测试:
http:// localhost / demo / hello
结果:
/ hello
要检查的内容:
- htaccess文件夹中,不要忘记添加
RewriteBase。 - 确保为您的目录启用了FollowSymLinks。有关详细信息,请参见此
链接。
I am using this htaccess file on my site to remove index.php.
RewriteEngine on
RewriteCond $1 !^(index\.php)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
But this file doesn't work.Rewriting is enabled in Apache module.Version of codeigniter used is 2.0.1.
解决方案
I've tested this without codeigniter, and it works.
I create a folder under htdocs, called "demo". I put ".htaccess" there with your content + additional line (RewriteBase):
RewriteEngine on
RewriteBase /demo/
# RewriteCond $1 !^(index\.php)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Then "index.php" below:
<?php
echo $_SERVER['PATH_INFO'];
Tested with: http://localhost/demo/hello
Result: /hello
Things to check:
- If you put ".htaccess" inside a folder, don't forget to add RewriteBase.
- Make sure FollowSymLinks is enabled for your directory. See this link for further information.
这篇关于Codeigniter htaccess不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文