2010-12-23 55 views
0

我使用雪豹,我有我的本地市场环境,我试图摆脱在URL中的index.php的...这里是我的.htaccess和笨不工作

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

我的配置文件有这个

$config['index_page'] = ""; 

但是当我访问网页时没有的index.php它不工作

这个作品

http://localhost/ci_example/index.php/site 

这并不

http://localhost/ci_example/site 

我试图按照this

也许我需要做一些与本地的conf文件...但我真的不知道什么,我不知道如何重新启动apache命令行...任何想法

+0

已与apache配置混淆? – yoda 2010-12-23 01:22:12

+0

我想现在...我将AllowOverride全部更改为无 – Trace 2010-12-23 01:37:45

回答

4

你是什么意思,当你说“它不工作”?你有错误吗?白屏? 500错误?

您是否确定您的httpd.conf文件的AllowOverride设置设置为All?如果不是,它可能不会使用您的.htaccess文件,这意味着重写规则不会被使用。

0

尝试在.htaccess文件

RewriteEngine On 
RewriteBase /ci_example 
0

这里添加RewriteBase的东西,对我的作品在OS X

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ /index.php/$1 [L] 
</IfModule> 

<IfModule !mod_rewrite.c> 
    ErrorDocument 404 /index.php 
</IfModule> 

以上应该为你工作,而无需任何修改。如果您正在托管文件夹,例如http://myserver.com/my_app/然后在两个地方更改/index.php/my_app/index.php

一定要进入config.php文件并更改url_protocolPATH_INFO

1

试试这个.htaccess代码&更改基本路径,它将适用于所有godaddy和其他hostnigs。


选项

选项-Multiviews 选项+的FollowSymLinks

启用国防部重写

RewriteEngine叙述在

您的网站的根目录的位置

如果写作为子目录ctories,你应该输入/子目录

RewriteBase/winscore

删除用户访问CodeIgniter的系统文件夹。

此外,这将允许您创建一个System.php控制器,

之前,这将不会成为可能。

如果您已将系统文件夹重命名,则可以替换'系统'。

的RewriteCond%{REQUEST_URI} ^系统。* 重写规则^(。*)$ /index.php?/$1 [L]

检查是否用户正试图访问一个有效的文件,

诸如图像或CSS文件,如果这不是真的它发送

请求到index.php

的RewriteCond%{REQUEST_FILENAME}!-f 的RewriteCond%{REQUEST_FILENAME}!-d

这个条件的允许访问图像和CSS

文件夹,并且robots.txt文件

的RewriteCond $ 1→!(index.php文件|图片|的robots.txt | CSS)

重写规则^(。*)$的index.php?/ $ 1 [L]


0

拷贝到你的.htaccess

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /CI_FOLDER/ 
#CI_FOLDER is the Location of your CI files. 

#Removes access to the system folder by users. 
#Additionally this will allow you to create a System.php controller, 
#previously this would not have been possible. 
#'system' can be replaced if you have renamed your system folder. 
RewriteCond %{REQUEST_URI} ^system.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

#When your application folder isn't in the system folder 
#This snippet prevents user access to the application folder 
#Submitted by: Fabdrol 
#Rename 'application' to your applications folder name. 
RewriteCond %{REQUEST_URI} ^application.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

#Checks to see if the user is attempting to access a valid file, 
#such as an image or css document, if this isn't true it sends the 
#request to index.php 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 



</IfModule> 

<IfModule !mod_rewrite.c> 
# If we don't have mod_rewrite installed, all 404's 
# can be sent to index.php, and everything works as normal. 
# Submitted by: ElliotHaughin 

ErrorDocument 404 /index.php 
</IfModule>