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
-
How to setup redirects
Hi Guys, If you're doing an SEO migration and have multiple versions of the same page example: Version 1: http://naturesway.com.au/superfood/super-maca-powder Version 2: https://naturesway.com.au/superfood/super-maca-powder Version 3: https://www.naturesway.com.au/superfood/super-maca-powder And you want to redirect them to a new URL (new site): New Site: https://www.naturesway.com.au/nw-superfoods-maca-powder-100g How would you ensure you redirect all the different versions of URL (versions 1,2,3) to the new URL on the new site? Cheers.
Intermediate & Advanced SEO | | brandonegroup0 -
Google Only Indexing Canonical Root URL Instead of Specified URL Parameters
We just launched a website about 1 month ago and noticed that Google was indexing, but not displaying, URLs with "?location=" parameters such as: http://www.castlemap.com/local-house-values/?location=great-falls-virginia and http://www.castlemap.com/local-house-values/?location=mclean-virginia. Instead, Google has only been displaying our root URL http://www.castlemap.com/local-house-values/ in its search results -- which we don't want as the URLs with specific locations are more important and each has its own unique list of houses for sale. We have Yoast setup with all of these ?location values added in our sitemap that has successfully been submitted to Google's Sitemaps: http://www.castlemap.com/buy-location-sitemap.xml I also tried going into the old Google Search Console and setting the "location" URL Parameter to Crawl Every URL with the Specifies Effect enabled... and I even see the two URLs I mentioned above in Google's list of Parameter Samples... but the pages are still not being added to Google. Even after Requesting Indexing again after making all of these changes a few days ago, these URLs are still displaying as Allowing Indexing, but Not On Google in the Search Console and not showing up on Google when I manually search for the entire URL. Why are these pages not showing up on Google and how can we get them to display? Only solution I can think of would be to set our main /local-house-values/ page to noindex in order to have Google favor all of our other URL parameter versions... but I'm guessing that's probably not a good solution for multiple reasons.
Intermediate & Advanced SEO | | Nitruc0 -
Redirect Juice?
Hello all! I have a partner site that is linking their product page (step 1) to our product page (step 2) and then we instantly forward them to our shopping cart page (step 3) with that product added. Will my product page (step 2) get the SEO juice from our partners link (step 1) even though we instantly forward to our shopping cart page (step 3)? Curious about ways to technically do this correctly. Thank you!
Intermediate & Advanced SEO | | Jamesmcd030 -
What is the Redirect Rule for corresponding https urls to new domain with the same https urls?
2 sites have the same urls but the owner wants just the 1 site. So I will be doing a 301 redirect with .htaccess from https://www.example.co.uk/sportsbook/SOCCER/today/ redirecting to https://www.example.com//sportsbook/SOCCER/today/ There are a lot of urls that are the same, so I was wondering what the rule is to put in the file please that will change them all to the corresponding urls? Would this be correct?... RewriteEngine on
Intermediate & Advanced SEO | | WSIDW
RewriteCond %{HTTPS_HOST} ^example.co.uk [NC,OR]
RewriteCond %{HTTPS_HOST} ^www.example.co.uk [NC]
RewriteRule ^(.*)$ https://example.com$1 [L,R=301,NC] Or would a simple rule like this work... redirect 301 / http://www.new domain.com/ If not correct could you please give me the correct rule, thanks! Then of course doing a change of address of address in webmaster tools after. Also... do I still need to do the forwarding from the https://www.example.co.uk/ domain provider after as well? Many thanks for your help in advance.0 -
Redirect Plugin: Redirecting or Rewriting?
Hey everybody! It's been a while since off the boards! I am reworking a site and I have been looking into their Redirection Plugin. I personally tend to lean towards just using the .htaccess because, well, why not. However, when looking deeper into the plugin I found myself a little confused with their redirection wording. RewriteRule ^/products/landing-page-october-2015/$ /products/special-education-news-october-2015/ [R=301,L] Is that the same thing as a classic Redirect 301?
Intermediate & Advanced SEO | | HashtagHustler0 -
Influence on CTR for high traffic keyword in url and redirect
I currently dominate on my site for a very high traffic keyword. My url contains this keyword in it along with the word "Free" in the beginning. Lets say my keyword is "This Keyword" then my url would be freethiskeyword.com. I rank 3rd for this keyword and generates me about 8k on a low month. I was just able to obtain my main keyword as my sole URL through an auction for a measly 2,000.00. (Very Excited about this). So now I have the URL thiskeyword.com What I want to know is what kind of influence can I expect with my new URL have in CTR. Since it is a high traffic keyword is there a automatic "Trust" factor that is involved and will users tend to click on thiskeyword.com as apposed to freethiskeyword.com? My Second Question I am torn as to what I should do with this new URL. Should I redirect my old URL to my new URL and keep both pointing to the same site? or should I try and dominate my niche and build a new site entirely. Since I currently make about 8k a month for third, if I were to build a separate site and be able to obtain 1st place for my new keyword that would generate me 2 amounts in income based on stats. CTR based on http://searchenginewatch.com/article/2049695/Top-Google-Result-Gets-36.4-of-Clicks-Study freethiskeyword.com = 8k/m for 3rd based on 10% of clicks (currently) thiskeyword.com = 24k/m for 1st based on 36% of clicks (in theory) If I keep each site separate and be able to have one site at 3rd and the other at 1st then I would be making about 32k a month. If I redirect my old url to my new url then I would only have 1st place (if I make it to first of course) and that would only make me 24k a month. It seems to me I should keep these sites separate to generate more income. I am torn what I should do. Also with the EMD penalty I am afraid to 301 my site to my new URL since it is my exact keyword as apposed to my current one. I am defiantly branded as "Free This Keyword" so moving it to thiskeyword.com could hurt me more than help (at least I think so) What you think?
Intermediate & Advanced SEO | | cbielich0 -
Modify .htaccess
Hi everybody, I need to modify the .htaccess in order to include a 301 redirect. But I am having some problems with this. I downloaded the file into my computer and then modified it with windows notepad, but when I upload it again to the server it is not working and turns down my website. Even if I do not change anything on it. So I guess there is a problem in the saving process. Any Idea or suggestion? Thanks, G.
Intermediate & Advanced SEO | | SilbertAd0 -
GeoIP - Redirect all but target country
My client would like to redirect all non UK traffic from their UK site to their main group site. I am intending to use a .htaccess redirect, like this: RewriteCond %{ENV:GEOIP_COUNTRY_CODE} !^GB$
Intermediate & Advanced SEO | | cottamg
RewriteRule ^(.*)$ http://www.group.com$1 [R,L] I have tested the redirect at it works fine. My question is if I put this in place would it have any negative SEO impact on the UK site?0