【问题标题】:Redirecting a URL from one domain to another in Apache containing character #在Apache中将包含字符#的URL从一个域重定向到另一个域
【发布时间】:2014-04-01 13:07:58
【问题描述】:

我试图使用 Apache mod_rewrite 将 URL 从一个域(例如pesdevelopment.ktm.local)重定向到另一个域(pestest.ktm.local)。

因此我在 Apache 中使用了以下条件和规则:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^pesdevelopment\.ktm\.local$ [NC]
RewriteRule ^(.*)$ http://pestest.ktm.local/$1 [R=302,L]

问题在于包含字符 # 的 URL 未正确重定向。该字符正在停止重写过程,并被重定向到到目前为止已重写的 URL,直到该字符出现在 URL 中。

示例: The URL pesdevelopment.ktm.local/Windchill/app/#ptc1/ 被重定向到 pestest.ktm.local/Windchill/app/

有谁知道如何处理这种情况?

【问题讨论】:

    标签: apache .htaccess mod-rewrite redirect


    【解决方案1】:

    以下应该可以工作

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^pesdevelopment\.ktm\.local$ [NC]
    RewriteRule ^(.*)$ http://pestest.ktm.local/$1%1 [R=302,L]
    

    【讨论】:

    • 您是否尝试过硬刷新页面?
    • 是的,我已经尝试过硬刷新。但它正在跳转到来自pesdevelopment.ktm.local/Windchill/app/#ptc1/tcomp/… 的pestest.ktm.local/Windchill/app/ 有什么想法吗?
    • 你的htaccess中还有其他规则吗?我尝试了链接beta.myssite.com/Windchill/app/#ptc1/tcomp/infoPage?oid=OR%3Awt.epm.EPMDocument%3A585162223&u8=1,它重定向它很好。
    • 不,htaccess 中没有规则
    猜你喜欢
    • 2015-10-24
    • 2019-01-12
    • 1970-01-01
    • 1970-01-01
    • 2020-10-01
    • 2017-05-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多