Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php .htaccess,mod_重写为域、子域和查询_Php_Apache_.htaccess_Mod Rewrite_Redirect - Fatal编程技术网

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
  • 重定向到实际重写的url

  • 我希望这能有所帮助,否则我可能需要调整代码中的某些内容

    我相信这一特定代码的答案应该是这样的:

    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
  • 重定向到实际重写的url

  • 我希望这能有所帮助,否则我可能需要调整代码中的某些内容。在许多小时后,我得到了:

    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!!