2012-01-24 34 views
0

我包括代碼,使URL工作和沒有.php。我包括下面寫的代碼文件夾無法加載,同時使URL和.php工作

RewriteEngine On  
    RewriteCond %{REQUEST_FILENAME} !-f  
    RewriteRule ^([^\.]+)$ $1.php [NC,L] 

現在的URL工作與不.php。對於例如如果我們把http://www.test.com/test.phphttp://www.test.com/test都起作用。但問題是文件夾無法加載。對於例如http://www.test.com/admin不加載。顯示了not found error。管理員是一個文件夾。任何想法?

回答

0
RewriteEngine On  
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^([^\.]+)$ $1.php [NC,L] 

只是嘗試這個...我認爲它的工作

1

如下嘗試:

RewriteEngine On  
    RewriteCond %{REQUEST_FILENAME}.php -f 
    RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [NC,L] 

這也將有一個目錄路徑工作。

+0

文件夾現在不加載 – asitha

+0

完成更改。它現在會工作 – 2012-01-24 06:10:45

1

嘗試使用PHP擴展,而不是去除這些代碼:

# To externally redirect /dir/foo.php to /dir/foo 
RewriteCond %{THE_REQUEST} ^GET\s.+\.php [NC] 
RewriteRule ^(.+)\.php$ /$1 [R=301,L,NC] 

# To internally redirect /dir/foo to /dir/foo.php 
RewriteCond %{REQUEST_URI} !\.php$ [NC] 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule . %{REQUEST_URI}.php [L] 

確保註釋掉現有的代碼