我想通过 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
我怎样才能用一条规则做到这一点?谢谢
我想通过 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
我怎样才能用一条规则做到这一点?谢谢
启用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]