logo

htaccess redirect url with space

logo

Ok a super quick post today as I wanted to share this with the world. I had some link building done for me a little while ago and I was just looking over the reports sent back to me. To my horror the links were actually pointing to http://www.mywebsite.com/%20 ! This of course was a 404 as I didn’t have a page that contained a space at the end of my URL.

There wasn’t much I could do as this work was completed some time ago so instead of crying about it I thought I would at least try to save some of this missed SEO link juice.

Here is the line I added to my htaccess to avoid at least some of this catastrophe:

Options +FollowSymlinks
RewriteEngine on
Redirect 301 “/ ” http://www.mysite.com/

This rule simply says that if my website is accessed with a space after the root slash then it will permanently redirect to my homepage.
If you needed a redirect for a page on your site that actually has a space in it you can use this technique as well, for example:

Options +FollowSymlinks
RewriteEngine on

Redirect 301 “/contact us.html” http://www.mysite.com/contact.php

I hope this helps some people!

Leave a Reply

logo
logo
Powered by Wordpress | Designed by Elegant Themes