Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you write a 301 redirect to an anchor point?

Is this valid and correct?

RewriteRule ^myOldPage.html$ /index.php#info [R]

I'm specifically interested about the #info part.

like image 406
nickf Avatar asked Dec 22 '08 16:12

nickf


People also ask

Can you 301 redirect an anchor?

If you're looking to change your podcast host from Anchor to another host, do not delete your Anchor account until you have redirected to your new host. You will need to initiate a 301 redirect to your new host first.

Can you redirect an anchor link?

One can use the anchor tag to redirect to a particular section on the same page. You need to add ” id attribute” to the section you want to show and use the same id in href attribute with “#” in the anchor tag.

Can you 301 redirect to another domain?

A 301 redirect is a permanent redirect from one URL to another. While they can redirect site page URLs, they can also redirect from one domain to another.


1 Answers

Yes. That's a valid 301 redirect (the HTTP standard allows for any valid URI to be provided as the redirect).

Now the caveat: Not all search engines may love the redirect. Google does a fantastic job of handling anchor tags (they even have a patent on this), while others will completely ignore them. As long as that's not an issue, the redirect is technically valid.

Update: If you're having trouble with mod_rewrite, try the NE (no escape) flag to prevent the # symbol from getting encoded:

RewriteRule ^myOldPage.html$ /index.php#info [R,NE]
like image 91
Chris Van Opstal Avatar answered Sep 30 '22 03:09

Chris Van Opstal