我已经为我的网站创建了一个htaccess文件,它将像http://www.example.com/fixture?id=1
这样的URL转换为像http://www.example.com/fixtures/1
这样的东西。
My htaccess file:
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^fixtures/('d+)*$ fixture.php?id=$1
这是我想要的,但不是完全SEO友好,所以我想传递两个变量home
和away
像http://www.example.com/fixture?id=1&home=Arsenal&away=Chelsea
。
然后重写URL,看起来像' http://www.example.com/fixtures/arsenal-vs-chelsea。
关于SO的重写规则有很多问题,但没有一个讨论在变量之间添加一小部分文本。我怎样才能使用重写规则添加URL的vs
部分?
您可以使用:
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^fixtures/([^/]+)-vs-([^/]+)/?$ fixture.php?home=$1&away=$2
重写:http://www.example.com/fixture?home=Arsenal&away=Chelsea