2012-10-22 112 views
0
<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/

    #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} ^main.* 
    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] 

    RewriteCond %{HTTP_HOST} . 

RewriteCond %{HTTP_HOST} !^www.domain.com [NC] 

RewriteRule (.*) http://www.domain.com/$1 [R=301,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> 

目前的URL被显示为http://www.domain.com/main/home删除应用程序文件夹的名字,但我宁愿把它显示为http://www.domain.com/home。我该如何改变它?如何代码点火器

回答

0

应该仅仅是这些线路(不乐观的第一,第二肯定虽然):

RewriteRule (.*) http://www.domain.com/main/$1 [R=301,L] 


RewriteRule ^(.*)$ /main/index.php?/$1 [L] 
+0

没有工作:/不断得到404 –

0

尝试添加此附近的您的规则上:

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^/?main/(.*)$ /$1 [L,R] 
+0

我得到一个内部服务器错误。我将它们添加到顶部并替换了这些行,并且都给我一个错误。 –

+0

@DigiJeff对不起,规则中的错字,'RewriteRle'应该是'RewriteRule' –

+0

越来越近了。我将它们替换为您的帖子所说的内容,现在得到一个非codeigniter 404错误“未找到” –

0

笨已建成在你的情况有帮助的路线。在routes.php中:

$route['home'] = 'main/home';