Forum Moderators: phranque

Message Too Old, No Replies

%20 at end of url

         

15medium

7:17 pm on May 4, 2011 (gmt 0)

10+ Year Member



Going through webmaster tools I see a bunch of pages that are coming to my site with %20 added to the link (probably a wysiwyg editor interpreting an additional space). Going to that persons page and looking at the source confirms the actual link has %20 appended my url.
Eg. [mydomain.com...]

Adding a space before hitting return when manully entering the url in a browser isn't a problem as I understand it. I beleive the browser ignores the whitespace. But adding the %20 to the link throws a 404 error.

I've been looking at rewrite rules for .htaccess but am having no luck. Any help would be greatly appreciated.
Thanks.

g1smd

7:52 pm on May 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is the space on the end of the URL path or is it on the end of the attached query string?

15medium

8:08 pm on May 4, 2011 (gmt 0)

10+ Year Member



The space is on the end of the url.
mydomain.com(forward slash)(percent)(20)
I think a wysiwyg editor applied "/%20" when the person adding the link may have accidently put a space after the url within the tag.

g1smd

8:24 pm on May 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The first part of solving the problem is defining EXACTLY what the problem is.

OK. It's on the end of the path. It is necessary to clarify this, because the code for it being on the end of a query string is COMPLETELY different.

RewriteRule ^([^\ ]*)\ $ http://www.example.com/$1 [R=301,L]


This redirect will likely be the very first redirect in your .htaccess file. Follow it with your other rules, and make your non-www to www rule the last one of the set.

15medium

8:41 pm on May 4, 2011 (gmt 0)

10+ Year Member



That was exactly what I have been looking for. Works a charm! Thank you very much.

topr8

10:55 pm on May 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi 15medium

welcome to WebmasterWorld

FYI if you use example.com it will be displayed, if you use any other web address the forum software turns it into a link, showing the domain name only