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
-
Moving to https: Double Redirects
We're migrating our site to https and I have the following question: We have some old url's that we are 301ing to new ones. If we switch over to https then we will be forced to do a double-redirect for these url's. Will this have a negative SEO impact? If so, is there anything that we can do about it?
Intermediate & Advanced SEO | | YairSpolter0 -
Help with htaccess
I just setup a WP install in a subfolder: domain.com/development/ However, there is an existing htaccess file in the root which contains the following: RewriteRule ^([A-Za-z_0-9-]+)$ /index.php?page=$1 [QSA]
Intermediate & Advanced SEO | | SCW
RewriteRule ^([A-Za-z_0-9-]+)/$ /index.php?page=$1 [QSA]
RewriteRule ^([A-Za-z_0-9-]+)/([a-z]+)$ /index.php?page=$1&comp=$2 [QSA]
RewriteRule ^([A-Za-z_0-9-]+)/([a-z]+)/$ /index.php?page=$1&comp=$2 [QSA] I need to leave the rules as-is due to the nature of CMS (not WP) under the root domain. Is it possible to include an exception or condition which allows URL requests containing /development/ to resolve to that folder? I tried to add: RewriteRule ^development/([A-Za-z_0-9-]+)$ /development/index.php?page=$1 [QSA] but this seems to send it in a loop back to the root. Thanks!!!0 -
301 redirects
Hello, I want to ditch about 1000 pages of a 2000+ page site. I believe the 301 redirect thing is the way to go but my expertise is limited. Is there a way to do a blanket redirect ie if a user or search engine looks for a page thats not there it all gets redirected to the index page or do I have to do each one manually? Thanks Ian
Intermediate & Advanced SEO | | jwdl0 -
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 -
Removing dashes in our URLs?
Hi Forum, Our site has an errant product review module that is resulting in about 9-10 404 errors per day on Google Webmaster Tools. We've found that by changing our product page URLs to only include 2 dashes, the module stops causing 404 errors for that page. Does changing our URL from "oursite.com/girls-pink-yoga-capri.html" to "oursite.com/girlspink-yoga-capri.html" hurt our SEO for a search for "girls pink yoga capri"? If so, by how much (assuming everthing else on the page is optimized properly) Thanks for your input.
Intermediate & Advanced SEO | | pano0 -
Not allowing me 301 Redirect
I am trying redirect my old site to my new site, both on the same domain. For one reason or another, I am having a hard time redirecting the some of the old urls to the new site. Please let me know how I can fix this issue. Below are the following old urls that are not allowing me to redirect: <colgroup><col width="636"></colgroup>
Intermediate & Advanced SEO | | Melia
| http://www.meliacaribetropical.com/press/melia-caribe-tropical-announces-fall-promotion.html |
| http://www.meliacaribetropical.com/press/melia-international-brand-overhaul.html |
| http://www.meliacaribetropical.com/spanish/accommodations/ |
| http://www.meliacaribetropical.com/spanish/dining/ |
| http://www.meliacaribetropical.com/spanish/entertainment/ |
| http://www.meliacaribetropical.com/spanish/events/ |
| http://www.meliacaribetropical.com/spanish/flintstones/ |
| http://www.meliacaribetropical.com/spanish/gallery/ |
| http://www.meliacaribetropical.com/spanish/gallery/beach.html |
| http://www.meliacaribetropical.com/spanish/gallery/dining.html |
| http://www.meliacaribetropical.com/spanish/gallery/pools.html |
| http://www.meliacaribetropical.com/spanish/press/ |
| http://www.meliacaribetropical.com/spanish/press/melia-caribe-tropical-announces-fall-promotion.html |
| http://www.meliacaribetropical.com/spanish/press/melia-international-brand-overhaul.html |0 -
301 Redirect To Corresponding Link No Matter The URL?
Hey guys I have hosting on Host Gator with I believe an apache web server. I need a code to put in the HT ACCESS to redirect all WWW URL's to their corresponding http URL. I haven't been able to get a code to work. For example, http://www.mysite.org/page1.html -> http://mysite.org/page1.html , without having to redirect hundreds of pages individually Here is the format my server uses in the HT ACCESS file for 301 redirects. RewriteCond %{HTTP_HOST} ^mysite.org$ [OR] RewriteCond %{HTTP_HOST} ^www.mysite.org
Intermediate & Advanced SEO | | DustinX
$RewriteRule ^Electric-Pressure-Cookers.html$ "http://mysite.org/Pressure-Cookers.html" [R=301,L] Thanks0 -
Expiring URL seo
a buddy of mine is running a niche job board and is having issues with expiring URLs. we ruled it out cuz a 301 is meant to be used when the content has moved to another page, or the page was replaced. We were thinking that we'd be just stacking duplicate content on old urls that would never be 'replaced'. Rather they have been removed and will never come back. So 410 is appropriate but maybe we overlooked something. any ideas?
Intermediate & Advanced SEO | | malachiii0