首页 > 解决方案 > Apache httpd server redirect url with anchor tag(fragment id) in it

问题描述

I'm setting up redirects in conf.d/ssl.conf of apache http server 2.2.34 for urls with anchor tag in it but it's not redirecting if the anchor tag is present in the target url of RewriteRule.

I have set of urls with different anchor tags in it and want to redirect each to a new url, like 1)https://example.com/index.php#version-test -> test.example.com/test.php 2)https://example.com/index.php#version-beta -> beta.example.com/beta.php

Here is the httpd.conf code which is not redirecting,

RewriteEngine on
RewriteRule "^/index.php#version-test" "test.example.com/test.php" [NE,R=301,L]
RewriteRule "^/index.php#version-beta" "beta.example.com/beta.php" [NE,R=301,L]

howerver if i remove anchor tag in it

RewriteRule "^/index.php" "test.example.com/test.php" [NE,R=301,L]

its redirecting properly to test.example.com/test.php.

is there any special case on how to handle urls with anchor tag in it? or am i missing something here?

标签: apacheredirecthttpd.conf

解决方案


推荐阅读