first, I apologize for any spelling error. I am french.
I\'d like your help for something that may have a simple fix, but I have not found anything specific to my case.<
If you had your domain pointed at blogger until now, and will have it pointed at your new server in the future, then all future requests will reach your new server automatically. So all you will have to do is set up the rewriting of all “old” URLs to the new targets on your new server.
With a Redirect
directive as mentioned by you in comments, you should be able to achieve that. Using this technique, you will need to use a Redirect
for each old URL you want to redirect to a new one.
If all of your old URLs follow the pattern of /yyyy/mm/post-name.html
, and all of your new URLs are just /post-name.html
with the post names being still the same, you might want to use a RewriteRule
instead:
RewriteEngine On
RewriteRule ^([0-9]{4})/([0-9]{2})/(.*)$ /$3 [R=301]
This will match on all incoming requests that start with four digits (the leading slash will have been stripped off at that point already), followed by a slash, followed by two digits and another slash, and then just “anything” after that, and will redirect it to that “anything”. It will be prefixed with the protocol and server name automatically. And the [R=301]
flag will make this a redirect with 301 status code.
That way, you could catch all of those old post URLs with just one rule, and would not have to write a Redirect
statement for each one individually.
(If you need more information about how this works, please consult the mod_rewite documentation first.)
If you are trying to redirect one url to another domain on existing page
like http://some-domain.com/2017/abc.html to http://another-domain.com/2017/abc.html
You can use following javascript
<script>
var url = location.href;
var newurl = url.replace('some-domain.com','another-domain.com';);
location.href=newurl;
</script>