2012-01-10 64 views
1

我在我的网站上设置了.htaccess文件,它在URL中显示SLUG文本作为页面名称,但没有扩展名。 例如真正的网址是如何使用.htaccess url重写添加.php扩展名?

www.mywebsite.com/page.php?page=about-us 

然后,它通过URL重写

www.mywebsite.com/about-us 

下面加载下面网址是我的.htaccess文件的代码

Options +FollowSymlinks 
RewriteEngine On 

RewriteCond %{REQUEST_URI} !^.*(images/|\.js|\.css).*$ [NC] 
RewriteRule ^([a-zA-Z0-9_-]+)$ /page.php?page=$1 

现在我想展示的php扩展所有网页,以便网址应如下所示

www.mywebsite.com/about-us.php 

我该怎么做?

+0

为什么要用.php扩展名。没有它,url看起来更干净。这对SEO也更好。 – Gerben 2012-01-10 13:42:32

+0

你是对的,但我的SEO不理解它。他希望带有.php扩展名的页面:P – aslamdoctor 2012-01-11 07:22:46

+0

只要告诉他这会损害他在搜索引擎中的页面排名。只有一点点,但至少你不会对那个男人撒谎。 – Gerben 2012-01-11 15:36:06

回答

2
Options +FollowSymlinks 
RewriteEngine On 

RewriteCond %{REQUEST_URI} !^.*(images/|\.js|\.css).*$ [NC] 
RewriteRule ^([a-zA-Z0-9_-]+)\.php$ /page.php?page=$1 
+0

nopes,它给内部服务器错误:( – aslamdoctor 2012-01-10 06:27:16

+1

在我的测试服务器上工作正常。请重新检查代码,因为David对原件所做的更改不应导致500错误。 – Gerben 2012-01-11 15:40:09