如何清除index.php在ubuntu服务器上的codeigniter? [英] How to remove index.php in codeigniter on ubuntu server?

查看:168
本文介绍了如何清除index.php在ubuntu服务器上的codeigniter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我研究了所有的问题stackoverflow从codeigniter中删除index.php,但仍然我无法做到。只有着陆页打开,其余页面为空。
我使用自己的 ubuntu linux服务器。
我的重写模块也打开。我尝试了 $ config ['uri_protocol'] 所有可能的值。 AUTO,PATH_INFO,QUERY_STRING,ORIG_PATH_INFO
我的htaccess代码在这里

  RewriteEngine on 
AddType text / x-component .htc
RewriteCond%{REQUEST_FILENAME}!-f
RewriteCond%{REQUEST_FILENAME}!-d
RewriteRule ^(。*)$ index.php / $ 1 [L]

vhost文件在此处

  DocumentRoot / home /black-sheep/black-sheep.org 

< Directory />
选项FollowSymLinks
AllowOverride FileInfo
< / Directory>

< Directory /home/black-sheep/black-sheep.org/>
选项+索引+ FollowSymLinks + MultiViews
AllowOverride所有
订单允许,拒绝
允许所有
< / Directory>


ScriptAlias / cgi-bin / / usr / lib / cgi-bin /
< Directory/ usr / lib / cgi-bin>
AllowOverride无
选项+ ExecCGI -MultiViews + SymLinksIfOwnerMatch
订单允许,拒绝
允许所有
< / Directory>

ErrorLog /var/log/apache2/error.log

#可能的值包括:debug,info,notice,warn,error,crit,
#alert ,出现。
LogLevel warn

CustomLog /var/log/apache2/access.log combined


我的网站网址是

  http://black-sheep.org/ 

这是在索引上回显 __ FILE __ 时的路径。 php

  /home/black-sheep/black-sheep.org/index.php 

它令人惊讶的wordpress网站在同一个服务器没有index.php运行良好与下面的htaccess。

 #BEGIN WordPress 
< IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^ index\.php $ - [L]
RewriteCond%{REQUEST_FILENAME}!-f
RewriteCond%{REQUEST_FILENAME}! -d
RewriteRule。 /index.php [L]
< / IfModule>

#END WordPress



我尝试过这个htaccess, t为我工作。



请向我建议解决方案。
提前感谢

解决方案

我面临着同样的问题,但能够纠正它。我给你完整的指示。



通过键入以下命令,首先检查mod_rewrite是否打开或不是来自Terminal:

  sudo a2enmod rewrite 

然后打开文件 apache2.conf ,位于下面提到的目录中

  / etc / apache2 / apache2 .conf 

查找< Directory / var / www / code>并更改 AllowOverride None AllowOverride All



如果不允许您保存文件,则意味着目录没有所需的权限。所以请通过运行下面的命令。



sudo chmod -R 777 / etc / apache2 / 保存文件。



现在写入 .htaccess 文件并通过放置以下代码保存文件。 p>

RewriteEngine on
RewriteCond $ 1!^(index\.php | resources | robots\.txt)
RewriteCond% {REQUEST_FILENAME}!-f
RewriteCond%{REQUEST_FILENAME}!-d
RewriteRule ^(。*)$ index.php / $ 1 [QSA,L]



然后通过以下命令重新启动apache服务

  sudo服务apache2 restart $希望这将有效... 

I have researched on all the question on stackoverflow to remove index.php from codeigniter but still i am unable to do it. Only landing page opens but rest of the pages are blank. I m using own ubuntu linux server. My rewrite module is also on. I tried $config['uri_protocol'] with all possible values. AUTO, PATH_INFO, QUERY_STRING, ORIG_PATH_INFO. My htaccess code is here

RewriteEngine on
AddType text/x-component .htc
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

vhost file is here

DocumentRoot /home/black-sheep/black-sheep.org

    <Directory />
            Options FollowSymLinks
            AllowOverride FileInfo
    </Directory>

    <Directory /home/black-sheep/black-sheep.org/>
            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 /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined

My website url is

http://black-sheep.org/

This is the path when i echo __FILE__ on index.php

/home/black-sheep/black-sheep.org/index.php

Its amazing that wordpress site on same server without index.php is running good with following htaccess.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

I tried with this htaccess also but it doesn't work for me.

Please suggest me the solution. Thanks in advance

解决方案

I was facing the same problem but able to correct it. I am giving you the full instruction. follow step by step..

First check whether mod_rewrite is on or not from Terminal by typing the below command :

sudo a2enmod rewrite

Then open file apache2.conf which is located in the below mentioned directory

/etc/apache2/apache2.conf

Find <Directory /var/www/> in the file and change AllowOverride None to AllowOverride All

If it is not allowing you to save the file, that means the directory don't have the required permission. so please give that by running the below command.

sudo chmod -R 777 /etc/apache2/ and then save the file.

Now write your .htaccess file and save the file by placing the below codes.

RewriteEngine on RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [QSA,L]

Then restart your apache service once by the below command

sudo service apache2 restart

Hopefully, then it will work...

这篇关于如何清除index.php在ubuntu服务器上的codeigniter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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