0

我想通过 RewriteEngine 获得这个:

mysite.com/translate/hola    referring to mysite.com/?goTo=translate&str=hola
mysite.com/buy/12            referring to mysite.com/?goTo=buy&id=12

我怎样才能用一条规则做到这一点?谢谢

4

1 回答 1

0

启用mod_rewrite.htaccess通过httpd.conf(如果尚未启用),然后将此代码放入您的DOCUMENT_ROOT/.htaccess文件中:

RewriteEngine On

ewriteCond %{REQUEST_FILENAME} !-f
ewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ /?goTo=$1&id=$2 [L,QSA]

参考:Apache mod_rewrite 简介

于 2013-11-03T14:01:42.210 回答