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 -
Htaccess maximum size?
Hello all, The company that develops our website recently contacted and asked me if we could remove a large amount of URL rewrites. I've described a few factors and my main questions below. Some information: One year ago we did a large migration. We went from 27 websites to one main website. We have got about 2000 rewrites in the htaccess file. And the file is 208kb. A lot of links from our old domains still have incoming traffic which are handled by the rewrite rules mentioned above. Questions:
Intermediate & Advanced SEO | | DPA
The company that develops our website said that the htaccess file is too large and is causing or could be causing us website performance issues. They have asked us to remove URL rewrites.
My question is:
a) How many rewrites is too much?
b) Is the filesize of the htaccess of any importance or is it just the amount of rewrites in the file?
c) Could we solve any potential server/website performance issues due to a large htaccess file in any other way? Increasing some values like 'post_max_size' or by any other solutions handled serverside? I do not have a lot of knowledge of htaccess rules but I've seen websites that handled over a million of rewrite rules. This is why I'm having doubts on whether removing URL rewrites is the only solution and possibly not the best solution for us. Hopefully you can help me any further and with the best way to proceed without losing traffic or causing 404 pages. Thanks in advance!
Iordache Voicu0 -
Hacked website - Dealing with 301 redirects and a large .htaccess file
One of my client's websites was recently hacked and I've been dealing with the after effects of it. The website is now clean of malware and I already appealed to Google about the malware issue. The current issue I have is dealing with the 20, 000+ crawl errors which are garbage links that were created from the hacking. How does one go about dealing with all the 301 redirects I need to create for all the 404 crawl errors? I'm already noticing an increased load time on the website due to having a rather large .htaccess file with a couple thousand 301 redirects done already which I fear will result in my client's website performance and SEO performance taking a hit as well.
Intermediate & Advanced SEO | | FPK0 -
HTML for URL markup
Hi, We are changing our URLs to be more SEO friendly. Is there any negative impact or pitfall of using <base> HTML-tag? Our developers are considering it as a possible solution for relative URLs inside HTML-markup in the Friendly URL context.
Intermediate & Advanced SEO | | theLotter0 -
URL Keyword Structure and Importance
Hey Guys, I've done quite a bit of research on this but still can't decide what the correct answer is, so was hoping the Moz community might be able to give some clarification. Say I have a URL **www.yourdomain.com/product/domain-names **is there any benefit in changing my site's backend structure (a relatively lengthly process) so the URL can read **www.yourdomain.com/domain-names **without the 'product' slug? I understand keywords in the URL can have a small impact on SEO, but does the positioning to this degree play any part? Any advice would be great.
Intermediate & Advanced SEO | | paragongroup
Cheers.0 -
Undo a 301 redirect
Hi there, 4 months ago I have done a redirect from one domain to another. Now, after about 120 days I have just a few results from the old domain indexed. The problem is that I believe that the old domain name had a really big impact on rankings, as it had the main keyword in the domain name. I'm wondering now if I could restore the old domain just by taking out the 301 instruction and how will search engines react. Do you have any studies on that? Would it be possible? Matt Cutts himself did it with his own domain, but he doesn't talk specifically on the effect of the rankings: http://www.thedotcomblog.com/seo/redirects-after-change-in-domain-name Thanks in advance for any help,
Intermediate & Advanced SEO | | SandraMoZ0 -
New URL : Which is best
Which is best: www.domainname.com/category-subcategory or www.domainname.com/subcategory-category or www.domainname.com/category/subcategory or www.domain.com/subcategory/category I am going to have 12 different subcategories under the category
Intermediate & Advanced SEO | | Boodreaux0 -
Duplicate titles but redirecting anyway (without redirects set up!!!)
Google has done a crawl of my site and is flagging up duplicate titles on my wordpress site. This appears to be due to the face that some posts are tagged in more than one category. I have just gone to make sure that each post just has one category and add redirects and I've noticed that all the duplicate title issues google has notified me about appear to redirect anyway. For example: http://www.musicliveuk.com/latest-news/live-music-boosts-australian-economy and http://www.musicliveuk.com/live-music/live-music-boosts-australian-economy have duplicate titles apparantly but the 1st url redirects to the 2nd one. I use the redirection plug in but have no redirection set up for that url so I'm a bit confused. And if they're redirecting anyway then why is google flagging up duplicate titles? Any help would be much appreciated.
Intermediate & Advanced SEO | | SamCUK1