我知道这个问题已经被问到了,我尝试了所有的方法,但是仍然不能从url中删除index.php。以下是我的详细信息
Ubuntu 12.10
PHP : 5.4.6
Mod_rewrite in on
CI verson: 2.1.htacess看起来像这样:
RewriteEngine On
RewriteBase /projectname
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 我也看了下面的链接,但没有运气..Cannot remove index.php from url CI based site
How to remove "index.php" in codeigniter's path
我的“/etc/apache2/sites available/default”是这样的:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>感谢您的帮助!!
发布于 2013-05-15 12:42:35
在application/config/config.php change中:
$config['index_page'] = 'index.php';至:
$config['index_page'] = '';每次更改apache配置文件时重新加载apache是一个好主意。
sudo /etc/init.d/apache2 reload或者:
sudo service apache2 reload或者:
sudo /etc/init.d/httpd reload(或者任何与您的平台等效的命令)
不管怎么说,这是我的.htaccess
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|static|robots\.txt|favicon\.ico|uploads|googlexxxxxxxx\.html|mobile.html)
RewriteRule ^(.*)$ index.php/$1 [L]发布于 2013-05-15 14:22:29
第1步:
将此添加到htaccess文件中
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>第2步:
删除codeigniter配置中的index.php
$config['base_url'] = '';
$config['index_page'] = '';第3步:
允许覆盖Apache配置中的htaccess (命令)
sudo nano /etc/apache2/apache2.conf并编辑文件&更改为
AllowOverride All对于www文件夹
第4步:
启用apache mod重写(命令)
sudo a2enmod rewrite步骤5 :
重新启动Apache (命令)
sudo /etc/init.d/apache2 restart发布于 2013-05-15 12:44:20
我的.htaccess
RewriteEngine on
RewriteCond $1 !^(index.php)
RewriteRule ^(.*)$ index.php/$1 [L]https://stackoverflow.com/questions/16556915
复制相似问题