![]() |
|
|
#1
|
||||
|
||||
|
How to 301 Redirect URL with %20 In It
Anyone know how to redirect a url with spaces in them. I get more and more 404 pages because of urls with %20 after them these days. I can't seem to get them to work in my .htaccess file.
|
|
#2
|
|||
|
|||
|
Untested (updated: tested, does work):
Code:
RewriteEngine on
RewriteRule [^\s]+ $0?%{QUERY_STRING}
__________________
SEO Tool - The killer search engine optimization tool. No. Really. The Search Engine Experiment - Discover if Google really giving you the most relevant results - No recip required. Last edited by nullbit; Feb 22nd 2005 at 11:15 am. |
|
#3
|
|||
|
|||
|
Quote:
J.D. |
|
#4
|
|||
|
|||
|
Quote:
__________________
SEO Tool - The killer search engine optimization tool. No. Really. The Search Engine Experiment - Discover if Google really giving you the most relevant results - No recip required. |
|
#5
|
||||
|
||||
|
I am not really doing it for browsers as much as I am for bots. Gbot in particular does not seem to want to remove the spaces.
That rewrite removed the spaces, but it also made it so that my style sheets were not used by FF |
|
#6
|
|||
|
|||
|
Do your CSS files have spaces in them? If yes, then the RewriteRule, will need a small revision.
__________________
SEO Tool - The killer search engine optimization tool. No. Really. The Search Engine Experiment - Discover if Google really giving you the most relevant results - No recip required. |
|
#7
|
||||
|
||||
|
no spaces in the file names
<edit>Ahh, but if I turn the RewriteEngine off, it works. ![]() But, I really would like to do a 301 as these are links coming from other sites, so if anyone knows how to do that I would love to hear how. </edit> |
|
#8
|
|||
|
|||
|
Can you post a sample URL/user agent from the log?
J.D. |
|
#9
|
|||
|
|||
|
A 301 using .htaccess is simple:
redirect 301 /source.htm /destination.htm Somehow you need to combine that with the rewrite module to capture & redirect all pages with trailing spaces. Right now, I can't think how you would do this. Edit: Of course, if the number of URLs is short, you could just add them all using the above sample.
__________________
SEO Tool - The killer search engine optimization tool. No. Really. The Search Engine Experiment - Discover if Google really giving you the most relevant results - No recip required. |
|
#10
|
||||
|
||||
|
I know how to do a 301 in .htaccess. But, it is not working with %20 in the url
|
|
#11
|
|||
|
|||
|
Quote:
Example: Code:
redirect 301 /source.htm\ \ \ /destination.htm Also using literal spaces, and quoting the source string might work: Example: Code:
redirect 301 "/source.htm " /destination.htm
__________________
SEO Tool - The killer search engine optimization tool. No. Really. The Search Engine Experiment - Discover if Google really giving you the most relevant results - No recip required. |
|
#12
|
||||
|
||||
|
ahh, there we go. Used the quotes as in the second example and it works perfectly. Thanks for your help.
|
|
#13
|
|||
|
|||
|
Quote:
Code:
RedirectMatch 301 "^(.+?) +$" $1 |
|
#14
|
|||
|
|||
|
Heck that is interesting.
Thanks for that |
|
#15
|
||||
|
||||
|
One piece was missing in this thread. How were the spaces getting tacked to the end of the URLs? I've never seen a hex space %20 tacked onto the end of a URL, although it is common when someone uses a space in a file name.
How is it gettin in there? |
|
#16
|
|||
|
|||
|
Quote:
J.D. |
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| redirect in htaccess | hurricane_sh | Apache | 6 | Jun 7th 2006 3:31 am |
| Craaaaaazy redirect - HELP | loewydesign | Co-op Advertising Network | 1 | Dec 16th 2004 7:31 pm |
| cpanel and redirect | vagrant | Site & Server Administration | 2 | Oct 14th 2004 6:15 am |
| Redirect phpBB2 forums and topics to IPB | bobafind | Apache | 1 | Sep 16th 2004 10:37 am |
| DNS Redirect | pk_synths | Apache | 10 | Mar 26th 2004 11:15 am |