[英].htaccess, mod_rewrite to domain, subdomain and queries
I have this link: 我有这个链接:
http://portal.tribee.com.br/pwreset.php?key=3ef73d15ddb6e307f5c12ffd5bed7d7f
And I need to make it like this: 我需要这样:
http://tribee.com.br/suporte/?ccce=pwreset&key=98f7459b8d46e3a54ed76965825c894a
As a matter of fact, the "pwreset.php" is one of the pages... There's clientarea.php also and others... If I can make a generic htaccess wich allows me to keep my main domain, would be the perfect match... I've already tryied lots of combinations.. such as: 事实上,“ pwreset.php”是其中的页面之一...还有clientarea.php和其他...如果我可以使通用htaccess允许我保留我的主要域名,那将是完美的匹配...我已经尝试了很多组合..例如:
RewriteCond %{REQUEST_URI} ^/pwreset\.php$
RewriteCond %{QUERY_STRING} ^key=(.*)$
RewriteCond %{HTTP_HOST} ^portal.tribee.com.br$
RewriteRule ^(.*)$ http://tribee.com.br/suporte/?ccce=&%1. [R=302,L]
RewriteRule ^$ http://tribee.com.br/suporte/?ccce=pwreset&key=%1 [R,L]
Does anyone has an idea how can I achieve this? 有谁知道我该如何实现? Tks! TKS!
I believe that the answer to this particular code should be something like this: 我相信这个特定代码的答案应该是这样的:
RewriteEngine On
RewriteBase http://tribee.com.br
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^pwreset.php?key=(.+)$ /suporte/?ccce=pwreset&key=$1 [R=302,L]
To simply explain what i did here: 简单地解释一下我在这里所做的事情:
pwreset.php?key=something
and rewrite that to the base/suporte/?ccce=pwreset&key=something
检查请求的查询是否包含pwreset.php?key=something
并将其重写为base/suporte/?ccce=pwreset&key=something
I hope this helped, else I might need to adjust something in the code 我希望这会有所帮助,否则我可能需要调整代码中的某些内容
After many hours, I got it: 几个小时后,我明白了:
RewriteCond %{HTTP_HOST} ^portal.tribee.com.br$
RewriteCond %{REQUEST_URI} ^(.*)\.php$
RewriteCond %{QUERY_STRING} ^key=(\w+)$
RewriteRule ^(.*)\.php$ http://tribee.com.br/suporte/?ccce=$1&key=%1 [R=301,L,NC]
If anyone needs in the future, the \\w+
allowed me to use the same name used to get the query to the generated URL. 如果将来有人需要,则\\w+
允许我使用用于查询生成的URL的相同名称。 Thanks for your Help Giovanni, simulating it over and over and taking your rewrite rule, leaded me to the answer! 感谢您的帮助Giovanni,一遍又一遍地模拟它,并采用了重写规则,使我找到了答案!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.