Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google      Sign In   
  • Create Account

Subscribe to HRA Now!

 



Are you a Google Analytics enthusiast?

Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE! 

 



 

 www.CustomReportSharing.com 

From the folks who brought you High Rankings!



Photo
- - - - -

Redirecting URLs With Spaces


  • Please log in to reply
4 replies to this topic

#1 qwerty

qwerty

    HR 10

  • Moderator
  • 8,695 posts
  • Location:Somerville, MA

Posted 04 August 2009 - 03:58 PM

A client of mine set up a bunch of new URLs and didn't 301 the old ones. I was poking around and found that a lot of the old URLs are still indexed, and that the pages are still up on the server at those old URLs, so they've got tons of duplicate content issues.

Obviously, we need to set up 301s as soon as possible, but here's the thing: those old URLs contain spaces, like domain.com/product name.html. Just to be on the safe side, would it be a good idea to put an entry in .htaccess for each URL with spaces and with the ASCII character for spaces (product name.html and product%20name.html), or am I OK with just one version of each?

#2 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 04 August 2009 - 08:25 PM

Spaces can be tricky Bob. There are several ways to do it, but which works best will depend upon your individual server's configuration. A couple of ways I've seen it work with .htaccess are:

mod_alias using quotes around the old url path so that it's treated as a literal string:
CODE
Redirect 301 "/path/to/old file.html" http://www.site.com/newfile.html


Or mod_rewrite using a backslash to escape the space:
CODE
RewriteRule ^/path/to/old\ file.html$ http://www.site.com/newfile.html [R=301,L]


Or, if the files that are currently there can be used to do a scripted redirect via php, asp or whatever you can do it right in those files. Of course then you need to leave 'em on the server, but that way is guaranteed to work since the files are presumably already loading when requested.

#3 1dmf

1dmf

    Keep Asking, Keep Questioning, Keep Learning

  • Active Members
  • PipPipPipPipPipPipPip
  • 2,167 posts
  • Location:Worthing - England

Posted 05 August 2009 - 06:46 AM

Just a note Qwerty, the ASCII code for a space if my memory serves me is 32 , %20 is URL encoded wink1.gif

Also if you are on a Windoze box I've found you can only redirect pages that physically exist on the server, you shouldn't need to worry about the spaces as you simply click the file in the IIS manager and choose redirect then enter the URL to redirect to and the redirection type (ie. permanent)



#4 qwerty

qwerty

    HR 10

  • Moderator
  • 8,695 posts
  • Location:Somerville, MA

Posted 05 August 2009 - 08:42 AM

You're right. I was wrong to refer to it as ASCII.

Anyway, I'm glad I asked. I'd forgotten about the need to escape the space in .htaccess. We'll probably end up just putting the redirect into the head of the old documents, just to make things easier.

#5 1dmf

1dmf

    Keep Asking, Keep Questioning, Keep Learning

  • Active Members
  • PipPipPipPipPipPipPip
  • 2,167 posts
  • Location:Worthing - England

Posted 05 August 2009 - 08:48 AM

lol - it's ok, boy the beatings I used to get on a IT professional X/HTML forum when I kept referring to the alt attribute as a tag!

Nice thinking batman!

If your pages are PHP or ASP, that's a good way to do it.

you could at a push use SSI & PERL, but it's a nasty way to have to do it if you have alternatives.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

We are now a read-only forum.
 
No new posts or registrations allowed.