Reputation: 330
I want to redirect my old website url to new website url. I wrote a redirect rule in .htaccess file. But the problem is, my old url contains a hash tag between the url params.
Redirect /de/home/#/de/about/blog/ https://www.example.com/about/blog/
Everything I've tried ignores the hash tag and either doesn't redirect at all. My old domain has the same host and after redesign, there are some changes in urls. This is the reason I want to redirect the old url.
If it is not possible using htaccess, is there any other methods to implement this?
or can I able to use the url without hash by matching the part of a url? I mean rewrite like this;
Redirect /(*)/de/about/blog/ https://www.example.com/about/blog/
Can you guys please help me. Thanks in advance.
Upvotes: 2
Views: 2000
Reputation: 111
It's not possible using htaccess. Everything from #
(URL fragment) is not sent to the server. The only way is using JavaScript, that's one of the reasons many people don't like hashbang.
Once you hashbang, you can’t go back. This is probably the stickiest issue. Ben’s post put forward the point that when pushState is more widely adopted then we can leave hashbangs behind and return to traditional URLs. Well, fact is, you can’t. Earlier I stated that URLs are forever, they get indexed and archived and generally kept around. To add to that, cool URLs don’t change. We don’t want to disconnect ourselves from all the valuable links to our content. If you’ve implemented hashbang URLs at any point then want to change them without breaking links the only way you can do it is by running some JavaScript on the root document of your domain. Forever. It’s in no way temporary, you are stuck with it.
You will find some useful information here: What's the shebang/hashbang (#!) in Facebook and new Twitter URLs for?
Upvotes: 2
Reputation: 1309
You need to make redirect on client side:
if (window.location.hash == "#/de/about/blog/") {
window.location = 'http://google.com.ua';
}
Upvotes: 3
Reputation: 944564
The fragment identify is designed to identify part of a document, it is handled entirely client side and will never be sent to the server.
The only way to redirect based on it is with client side JavaScript.
Upvotes: 4