2014-05-17 86 views
1

我試着在URL擺脫「的index.php」使用下面的重寫code.but它不工作 請幫我修復這個bug笨的URL刪除/index.php/部分

# Development 
RewriteEngine On 
RewriteBase /mvcTestApp/blog/ciBlog/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond $1 !^(index\.php|images|scripts|styles|vendor|robots\.txt) 
RewriteRule ^(.*)$ index.php/$1 [L] 
+0

你可以發佈Apache訪問/錯誤日誌,或至少告訴什麼是不工作。 – greut

回答

0

這htaccess的是工作me.Try這一點。

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

這是我對CodeIgniter的重寫規則套件。請閱讀在線評論:

## Rewrite rules 
<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/

    # Remove the "index.php" part of URI 
    # Remove access to "codeigniter" and "data" folders 
    RewriteCond %{REQUEST_URI} ^(codeigniter|data).* 
    RewriteRule ^(.*)$ /index.php?/$1 [L] 

    # Block access to "hidden" directories whose names begin with 
    # a period. e.g. .git, .svn 
    RewriteCond %{SCRIPT_FILENAME} -d 
    RewriteCond %{SCRIPT_FILENAME} -f 
    RewriteRule "(^|/)\." - [F] 

    # WWW redirect 
    RewriteCond %{HTTP_HOST} ^(?!www\.).* 
    RewriteCond %{HTTP_HOST} ^(?!dev\.).* 
    RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,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 the root index.php. 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule> 
1

在.htaccess文件中添加以下內容。

#Rewrite index.php 
#Start using rewrite engine 
RewriteEngine On 
#Rewrite condition 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

#Whenever index.php is there in the url, it will rewrite to/automatically 
RewriteRule .* index.php/$0 [PT,L] 

檢查此鏈接更多的細節:http://subhra.me/remove-index-php-urls-codeigniter/