我想通过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
如何使用一条规则执行此操作? 感谢
答案 0 :(得分: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]