如何从 UBUNTU 中的 codeigniter 中删除 index.php [英] How to remove index.php from codeigniter in UBUNTU

查看:13
本文介绍了如何从 UBUNTU 中的 codeigniter 中删除 index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题已经有人问过了,我尝试了所有这些,但仍然无法从 url 中删除 index.php.这是我的详细信息

I know this question is being ask already, i tried all those but still unable to remove index.php from url. Here are my details

Ubuntu 12.10
PHP : 5.4.6
Mod_rewrite in on
CI verson: 2.1

.htacess 看起来像:

.htacess look like:

RewriteEngine On
RewriteBase /projectname

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]  

我也看了下面的链接,但没有运气..无法从基于 url CI 的站点中删除 index.php

I also look at the below link but no luck.. Cannot remove index.php from url CI based site

如何删除index.php"在 codeigniter 的路径中

我的/etc/apache2/sites-available/default"是这样的:

My "/etc/apache2/sites-available/default" is look like this:

<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>

感谢任何帮助!

推荐答案

application/config/config.php 中更改:

$config['index_page'] = 'index.php';

到:

$config['index_page'] = '';

每次更改 apache 配置文件时都重新加载 apache 是个好主意.

it is a good idea to do apache reload everytime you change an apache config file.

sudo /etc/init.d/apache2 reload

或:

sudo service apache2 reload

或:

sudo /etc/init.d/httpd reload

(或任何适用于您平台的等效命令)

(or whatever is the equivalent command for your platform)

就其价值而言,这是我的 .htaccess

for what it is worth, here is my .htaccess

RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index.php|static|robots.txt|favicon.ico|uploads|googlexxxxxxxx.html|mobile.html)
RewriteRule ^(.*)$ index.php/$1 [L]

这篇关于如何从 UBUNTU 中的 codeigniter 中删除 index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆