2015-05-12 158 views
0

我在我的网站有2个类别一个是CONTRY,另一个是TOWN。 现在非友好的URL看起来是这样的:.htaccess友好的url重写

  1. mywebsite.com/country.php?url=clients-in-england(为国家类别)
  2. mywebsite.com/town.php?url =客户,在伦敦(用于城镇类)

现在我想那些nonfriendly的URL是这样的:

  1. mywebsite.com/clients-in-england
  2. mywebsite.com/clients-in-london

我怎样才能准确地做到这一点使用的.htaccess 我当前的htaccess代码如下:

Options -Indexes 
Options +FollowSymLinks 
RewriteEngine On 

RewriteRule ^([a-zA-Z0-9_-]+)$ page.php?url=$1 
RewriteRule ^([a-zA-Z0-9_-]+)/$ page.php?url=$1 

回答

1

您可以使用:

Options +FollowSymLinks -Indexes 
RewriteEngine On 

RewriteCond %{THE_REQUEST} /(country|town)\.php\?url=([^\s&]+) [NC] 
RewriteRule^/%1/%2? [R=302,L,NE] 

RewriteRule ^(country|town)/([^/.]+)/?$ $1.php?url=$1 [L,QSA,NC] 

RewriteRule ^([\w-]+)/?$ page.php?url=$1 [L,QSA] 
+0

我不想任何文件夹只是简单mywebsite.com/clients-in-england –

+0

你写道:'mywebsite.com/country/clients-in-england'问题 – anubhava

+0

我的不好,抱歉。我想说mywebsite.com/clients-in-england –