2015-02-24 86 views
1

這裏我想從我的codeigniter應用程序中的URL中刪除index.php。htaccess rewriterule在codeigniter中不工作

對於這一點,我寫.htaccess文件是這樣的:

# Turn on URL rewriting 
RewriteEngine On 

# Installation directory 
# RewriteBase /projectname/ 

# Protect hidden files from being viewed 
<Files .*> 
    Order Deny,Allow 
    Deny From All 
</Files> 

# Protect application and system files from being viewed 
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L] 

# Allow any files or directories that exist to be displayed directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

# Rewrite all other URLs to index.php/URL 
RewriteRule .* index.php [PT] 

它在xx.xx.xx.xxx服務器和mydomain.com工作。在這裏,我試圖製作一個相同的副本到另一臺服務器yy.yy.yy.yyy。在此,重寫URL不起作用。如果我使用'yy.yy.yy.yyy/index.php/login',它的工作正常。但是'yy.yy.yy.yyy/login',它會拋出'在此服務器上找不到請求的URL /項目名稱/登錄名'。錯誤。

回答

0

你的主目錄下的.htaccess從config.php文件

Options +FollowSymLinks 
Options -Indexes 

<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))"> 
    Order deny,allow 
    Deny from all 
</FilesMatch> 

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

請勿觸摸應用程序目錄的的.htaccess文件試試這個,然後刪除index.php文件。