Welcome to WebmasterWorld Guest from 54.158.99.141

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

301 old to URL to new one with spaces %20

     
12:38 pm on Sep 11, 2007 (gmt 0)

Full Member

10+ Year Member

joined:Aug 31, 2002
posts: 284
votes: 0


I've got to redirect an old URL to a new one with spaces in it.

Have been using the following successfully where there are no spaces, but it crashes when spaces are included in the new destination name...

RewriteCond %{query_STRING} ^q=12345$
RewriteRule ^path/file\.php$ /path2/Place Name/Other Name? [R=301,L]

equally the following doesnt work either:

RewriteCond %{query_STRING} ^q=12345$
RewriteRule ^path/file\.php$ /path2/Place%20Name/Other%20Name? [R=301,L]

Help much appreciated!

[edited by: Adam_C at 12:41 pm (utc) on Sep. 11, 2007]

12:40 pm on Sept 11, 2007 (gmt 0)

Full Member

10+ Year Member

joined:Aug 31, 2002
posts:284
votes: 0


ok, nailed it

RewriteCond %{query_STRING} ^q=12345$
RewriteRule ^path/file\.php$ "/path2/Place Name/Other Name?" [R=301,L]

12:56 pm on Sept 11, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


Wow, that's new! I've never seen a quoted substitution URL before, and it's great to know that it works.

The usual solution is to use %20 for the space and use the [NE] flag on the rule, or to escape the space with a preceding backslash ( e.g. "\ " ). But quoting the string is easier and looks much more readable.

Thanks for posting your solution!

Jim

7:40 pm on Sept 11, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


Using spaces in URLs is so problematical. They are often encoded as %20 and make URLs unreadable. Additionally, sometimes they become double encoded (where the % sign itself is encoded again) and that can cause all sorts of problems.

Can I suggest that you use hyphens or dots between words? Is there a good reason why spaces have been used? If the URL hasn't yet been indexed, I would strongly suggest that it be changed, to lose the spaces.

If it is a script that generates the pages from a database, then it is fairly easy to take the text that I assume you currently use for both the title and for the URL and add hyphens or dots between the words for whatever you are going to use for the URLs and for the links to those pages.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members