2016-03-01 104 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