2016-03-01 153 views
0

我想刪除single.php?我會如何去呢?,我已經嘗試了以下內容:Htaccess從url中刪除文件名

so EG。 www.mysite.com/single.php/contact/

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME}.php -f 
    RewriteRule ^([^\.]+)$ $1.php [QSA,NC,L] 
</IfModule> 
+0

需要它只是'single.php'? – anubhava

+0

是:)想要替換single.php文件,以便新的URL讀取www.sitename.com/page1而不是www.sitename.com/single.php/page1 –

回答

0

您可以使用這些規則:

RewriteEngine On 
RewriteBase/

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule ^(.+?)/?$ $1.php [L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+?)/?$ single.php/$1 [L] 
+0

沒有指定輸入文件。錯誤我得到 –

+0

有規則測試和工作在我的Apache。檢查你的Apache error.log的原因是500 – anubhava