2013-05-01 108 views
0

我的文件結構是類似以下內容:如何configut上笨的public_html htaccess文件

application 
public_html 
     .htaccess 
     index 

的application/config/config.php文件

 here i have set blank my base_url and index page 

的.htaccess

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

但sti LL如果我的index.php用戶她,我有使用虛擬主機httpd.conf中

<VirtualHost *:80> 

    ServerAdmin [email protected] 
    DocumentRoot "c:\wamp\www\dab\public_html" 

    ServerName dab 
    ServerAlias www.dab 
    ErrorLog "logs/localhost-error.log" 
    CustomLog "logs/localhost-acces.log" common 

    <directory "c:\wamp\www\dab\public_html"> 
     Options FollowSymlinks 
     AllowOverride None 
     Order Deny,Allow 
     Deny from all 
     Allow from 127.0.0.1 
    </directory> 
</VirtualHost> 

什麼是提前

不使用的index.php在URL

感謝解決方案

回答

1
替換以下變量

確保你已經在你的apache的conf啓用了mod_rewrite模塊,然後嘗試看起來更像這樣一個.htaccess:

<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} ^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> 
+0

不工作,我試了一下 – SAR 2013-05-06 05:50:11

1

查找以下行你的application/config/config.php文件

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

集日e變量如下所示。

$config['index_page'] = ''; 

就是這樣,它爲我工作。

如果沒有進一步的工作,嘗試用這些參數( 'AUTO', 'PATH_INFO', 'QUERY_STRING', 'REQUEST_URI' 和 'ORIG_PATH_INFO')逐一

$config['uri_protocol'] = 'AUTO'; 
+0

它爲u說,但仍然沒有工作 如果我我們在本地主機它的作品,但在這裏,我已添加虛擬主機 – SAR 2013-05-01 09:23:44