Php .htaccess,mod_重写为域、子域和查询
我有这个链接:Php .htaccess,mod_重写为域、子域和查询,php,apache,.htaccess,mod-rewrite,redirect,Php,Apache,.htaccess,Mod Rewrite,Redirect,我有这个链接: http://portal.tribee.com.br/pwreset.php?key=3ef73d15ddb6e307f5c12ffd5bed7d7f 我需要这样做: RewriteEngine On RewriteBase http://tribee.com.br RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^pwreset.php?key=(.+)$
http://portal.tribee.com.br/pwreset.php?key=3ef73d15ddb6e307f5c12ffd5bed7d7f
我需要这样做:
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]
http://tribee.com.br/suporte/?ccce=pwreset&key=98f7459b8d46e3a54ed76965825c894a
事实上,“pwrete.php”是其中一个页面。。。还有clientrea.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]
简单解释一下我在这里做了什么:
pwrete.php?key=something
,并将其重写到base/support/?ccce=pwrete&key=something
我希望这能有所帮助,否则我可能需要调整代码中的某些内容我相信这一特定代码的答案应该是这样的:
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]
简单解释一下我在这里做了什么:
pwrete.php?key=something
,并将其重写到base/support/?ccce=pwrete&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一遍又一遍地模拟它,接受你的重写规则,引导我找到了答案 几个小时后,我明白了:
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一遍又一遍地模拟它,接受你的重写规则,引导我找到了答案 重写库返回错误500页…:(我很有信心它会是解决方案…但仍在尝试…有想法吗?Tks!!重写库返回一个错误500页…:(我很有信心它会是解决方案…但仍在尝试…有想法吗?Tks!!