[英]Remove index.php of codeigniter
Yes, another one of these. 是的,另外一个。 I've tried everything I could find on the search with no luck.
我已经尝试了一切我在搜索中找不到运气的东西。
In my httpd.conf (running centos and apache2): 在我的httpd.conf(运行centos和apache2)中:
<VirtualHost *:80>
ServerName www.domain.com
ServerAlias domain.com *.domain.com
DocumentRoot /var/www/html/domain.com
</VirtualHost>
in my htaccess in /var/www/html/domain.com: 在我的htaccess /var/www/html/domain.com中:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
Nothing seems to be working. 似乎没有什么工作。
I've tried adding 我试过添加
RewriteBase /
I've tried switching the last line to: 我已经尝试将最后一行切换为:
RewriteRule ^(.*)$ /index.php/$1 [L]
You need to make sure that in your virtual host you have: 您需要确保在虚拟主机中拥有:
<Directory "/path...to directory">
Order allow,deny
Allow from all
Allowoverride all
</Directory>
<IfModule mod_rewrite.c>
RewriteEngine on
</IfModule>
The rules in the original post (and in the CI user guide) can be used to allow URLs to work without /index.php/
in them, but will NOT remove /index.php/
from existing URLs. 原始帖子(以及CI用户指南)中的规则可用于允许URL在没有
/index.php/
情况下工作,但不会从现有URL中删除/index.php/
。
You can set $config['index_page'] = '';
你可以设置
$config['index_page'] = '';
(removing index.php
) in the CI config to remove index.php
from CI-generated URLs. (去除
index.php
在CI配置),以除去index.php
从CI-生成的URL。
If the original rules do not work, please give these rewrite rules a try: 如果原始规则不起作用,请尝试这些重写规则:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
Two points of advice: 两点建议:
1.) Be sure you are saving/editing the .htaccess file into the root of your project folder, and not the .htaccess in your /applications folder. 1.)确保将.htaccess文件保存/编辑到项目文件夹的根目录中,而不是/ applications文件夹中的.htaccess。 Such that, if my applications folder was at, project/application, don't edit the project/application/.htaccess file.
这样,如果我的应用程序文件夹位于项目/应用程序,则不要编辑项目/应用程序/ .htaccess文件。 You need your file to be located at project/.htaccess
您需要将文件放在project / .htaccess中
2.) Use the following in your .htaccess file: 2.)在.htaccess文件中使用以下内容:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.