1

我有链接:domain.com/activate/ 这很有效,在激活页面中我得到了表格。如果我运行它,我会得到: domain.com/activate/?code=heresomecodething

但这不起作用。我的原始网址是:domain.com/index.php?p=activate&code=heresomecodething 我希望我像这样工作:domain.com/activate/code=heresomecodething 我该怎么做?

我的 htaccess:

 RewriteEngine On
RewriteRule ^(.*)/$ index.php?p=$1 [L]

我希望你能理解我。

谢谢!- 马林

4

1 回答 1

0

尝试:

RewriteEngine On
RewriteRule ^([^/]+)/(.*)$ /index.php?p=$1&$2 [L,NE]

您要提交的 URI 看起来像/activate/code=heresomecodething,因此([^/]+)匹配 theactivate(.*)匹配 the code=heresomecodething,两者都通过$1and进行反向引用$2

/index.php?p=$1&$2

将会:

/index.php?p=activate&code=heresomecodething

此规则采用看起来像的 URI,/activate/code=heresomecodething并在内部重写(在幕后/浏览器完全不受影响)带有查询字符串的 URI。

于 2012-11-02T21:09:12.877 回答