Htaccess Redirect with %C2%A0 in URL
-
Below is my setup for redirects in .htaccess file in my root word press installation.
- The www to non-www works well, so no problems there
- Other page redirects work well, too (example: redirect 301 /some-page/ http://mysite.com/another-page/ (I didn't post those because I have a few too many : )
So here it goes...
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.mysite.com$ [NC]
RewriteRule ^(.*)$ http://mysite.com/$1 [R=301,L]BEGIN WordPress
<ifmodule mod_rewrite.c="">RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]</ifmodule>END WordPress
redirect 301 /archives/10-college- majors/ http://mysite.com/archives/10-college-majors/
redirect 301 /archives/10-college-%20majors/ http://mysite.com/archives/10-college-majors/
redirect 301 /archives/10-college-%C2%A0majors/ http://mysite.com/archives/10-college-majors/
I'm having a problem with the last 301 redirect:
- redirect 301 /archives/10-college-%C2%A0majors/ http://mysite.com/archives/10-college-majors/
not working... As you can see I've tried using other varations of the "space" but no go. I also used a redirect in cPanel's Redirect screen; testing all the possible options + wildcard
I've also tried this:
- http://serverfault.com/questions/201829/using-special-characters-in-apache-mod-rewrite-rule (perhaps unsuccessfully, because it caused a 500 server error and it's a different situation in my case)
I also saw something here:
but I don't know if it works and how I would implement that + do so without compromising ALL other redirects.
Note: the URL displays with a space in the address bar of all major web browsers: http://mysite.com/10-college- majors/ and goes to a 404 page
I have a goregous page / PR6 / high authority site linking to the URL on my site, but they copied the URL with a space somehow. I contacted the person responsible for the website and he claims it works fine (aka he didn't check it).
Is there a clean way to redirect ONLY this problematic URL without compromising other redirects, etc?
Any ideas would be great. I'll respond with progress. Thanks in advance.
UPDATE the redirect works, and it did work. Even so, when looking at source of page linking to mine, the URL looks like this: ``` http://mysite.com/archives/10-college- majors/ Clicking the URL in Source View in FireFox takes me to ``` http://mysite.com/archives/10-college-%C2%A0majors/ none of my 301 redirects should direct there. I don't have any redirect plugins either.
-
I had problems getting redirects for URLs with spaces in them working correctly on my own site, and ended up using the Redirection plugin as well, and it's worked like a charm.
The other thing I like about this plugin is the ability to see 404 errors and to set up redirects straight from that 404 list. If someone has linked to you and accidentally did a typo in the URL somewhere, or a comma got included in the hyperlink, you can see it in the 404 list and fix it right there.
-
I ended up doing what you recommended. I downloaded the Redirection plugin.
I copied the URL with %C2%A0 in it and setup a target URL without the space and the results were great. I double checked all my other redirects, in case of conflict - no worries there. Also I used the server header checker tool and saw a great 301 returning a 200 OK. That felt good.
I still wanted to learn how to do it vs. how to "plug it" - see my thread here for all other woes related to this URL
In the meanwhile I found out that it wasn't several great sites that were linking wrongly, it's like close to ten (some .edu, .org, and even one .mil - editorial links).
Sometimes it's better to conform than to be a "purist". I saved tons of time by doing what I contemplated doing initially. Thanks for the push and for the help, Dan.
-
That is an idea I have contemplated, but I'm trying to limit the number of plugins. I have other redirects working very well, but this one with the "space" is so pesky. I would love to solve the issue using .htaccess if possible. I am looking into other solutions and will post here when anything comes up. In the meanwhile, I hope others may help, too.
Dan, thank you for your great feedback.
-
Instead of using the htaccess file, you should download a wordpress plugin called SImple 301 Redirects. It's very easy. Maybe if you do the 301 reidrects at the wordpress plugin level then wordpress can handle them better.
-
Dan, Thanks for your response. I tried your recommendations. None worked. http://mysite.com/archives/10-college- majors/ is what I found in the source code, but my AWSTATS and Google Webmaster Tools point to a URL %C2%A0 as the culprit 404 error. I double checked if the URL registering in my Stats and Google WT is from that PR6 page - yes it is. There's no space in the URL from source code and I did a 301 redirect with this variation (see original post) The url only shows the space in the browser's address bar, but not in source. UPDATE the redirect works, and it did work. Even so, when looking at source of page linking to mine, the URL looks like this: ``` http://mysite.com/archives/10-college- majors/ Clicking the URL in Source View in FireFox takes me to ``` http://mysite.com/archives/10-college-%C2%A0majors/ none of my 301 redirects should direct there. I don't have any redirect plugins either.
-
Can't you look up the source code of the page with the link to you? In there you should find your link at
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Htaccess - Redirecting TAG or Category pages
Hello Fellow Moz's, We have an issue redirecting some /TAG and /Category pages to inner pages. As an example we use: RedirectMatch 301 /category/Sample-Category(.*) https://OurDomain.com.au/New-Page//$1 That works well. The issue is we have other categories and tags that are named similar to /Sample-Category As an example, if we try to redirect /Sample-Category-1 to /New-Page-1 - it will not work, and redirects to /New-Page I assume this is because /Sample-Category is already being redirected, so anything after /Sample-Category like -1 or -2 or -3 etc, will not be recognized. Anyone know of a workaround?
Intermediate & Advanced SEO | | Jes-Extender-Australia0 -
Changing URLs
URLs of my web pages are based on the titles of pages. For sampel, if a title page is called "product ABC", then the URL for this page is /product-abc. Google and all other search engines have indexed all pages. Now I want to change the titles of some sites. Should I change the URLs accordingly, or should I rather leave URLs as they are. SEO Best Practice says that keywords must be placed both in the title, and in the URL. I think that Google will think that pages have douplicate content with diffrent titles, and it comes to many 404 error, if I change the URLs. What do you recommend in this case?
Intermediate & Advanced SEO | | kian_moz0 -
Internal links and URL shortners
Hi guys, what are your thoughts using bit.ly links as internal links on blog posts of a website? Some posts have 4/5 bit.ly links going to other pages of our website (noindexed pages). I have nofollowed them so no seo value is lost, also the links are going to noindexed pages so no need to pass seo value directly. However what are your thoughts on how Google will see internal links which have essential become re-direct links? They are bit.ly links going to result pages basically. Am I also to assume the tracking for internal links would also be better using google analytics functionality? is bit.ly accurate for tracking clicks? Any advice much appreciated, I just wanted to double check this.
Intermediate & Advanced SEO | | pauledwards0 -
Spaces in URL line
Hi Gurus, I recently made the mistake of putting a space into a URL line between two words that make up my primary key word. Think www.example.com/Jelly Donuts/mmmNice.php instead of www.example.com/JellyDonuts/mmmNice.php This mistake now needed fixing to www.example.com/Jelly Donuts/mmmNice.php to pass W3, but has been in place for a while but most articles/documents under 'Jelly Donuts' are not ranking well (which is probably the obvious outcome of the mistake). I am wondering whether the best solution from an SEO ranking viewpoint is to: 1. Change the article directory immediately to www.example.com/JellyDonuts/mmmNice.php and rel=canonical each article to the new correct URL. Take out the 'trash' using robots.txt or to 301 www.example.com/Jelly Donut to the www.example.com/JellyDonut directory? or perhaps something else? Thanks in advance for your help with this sticky (but tasty) conundrum, Brad
Intermediate & Advanced SEO | | BM70 -
Redirect one store to another...
Here's the situation: 2 online stores. Store A is doing really well, traffic, sales, and keyword ranking wise. Store B, not so much. Owner wants to redirect all links from store B to store A and then possibly re-brand store A and give it a different URL. This is a slow time, sales pick up in spring. I would like opinions on this from anyone who has done this or knows about it. Risks, benefits, best practices on going about it, etc... Thank you, Lisa
Intermediate & Advanced SEO | | Freelancer130 -
Redirection - Seo trick?
Hi, After analyzing the site I found several Redirections of exact match domains. With different domain name extensions. Is Seo trick? Is the second website which i fond that is using this technique. Can anyone gives more details? Thanks
Intermediate & Advanced SEO | | nyanainc0 -
Quoestion about 301 redirect
Hey, I have interesting questions regardin 301 redirect (At least I think it's Interesting:) ) So i have this websites that compares different lenders, url below 🙂 If you go to the homepage then the first thing you see is different loan amounts in 50-99 euro range. Also you can check out different loan amounts like 100-149€, 150-199€, 200-249€ and so on. For now i have used 301 redirect and Noindex and Nofollow for all the different "loan amounts" urls. Examples below etc Is it a good idea to use 301 on all such pages to point to the homepage?
Intermediate & Advanced SEO | | TauriU0 -
301 Redirect With A Message And Delay
Hello, I'd like to sell a site I own. I'd like the site to be redirected to the buyers site with a 301 redirect. But I'd like the viewer to be informed that the site was purchased by this company and they will be redirect in 5 seconds.I'd like for the redirect to be a complete 301 and pass as much linklove as possible. Are you familiar with how to do this? Thanks, Tyler
Intermediate & Advanced SEO | | tylerfraser0