[英].htaccess, mod_rewrite to domain, subdomain and queries
我有這個鏈接:
http://portal.tribee.com.br/pwreset.php?key=3ef73d15ddb6e307f5c12ffd5bed7d7f
我需要這樣:
http://tribee.com.br/suporte/?ccce=pwreset&key=98f7459b8d46e3a54ed76965825c894a
事實上,“ 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]
有誰知道我該如何實現? TKS!
我相信這個特定代碼的答案應該是這樣的:
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]
簡單地解釋一下我在這里所做的事情:
pwreset.php?key=something
並將其重寫為base/suporte/?ccce=pwreset&key=something
我希望這會有所幫助,否則我可能需要調整代碼中的某些內容
幾個小時后,我明白了:
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]
如果將來有人需要,則\\w+
允許我使用用於查詢生成的URL的相同名稱。 感謝您的幫助Giovanni,一遍又一遍地模擬它,並采用了重寫規則,使我找到了答案!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.