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
-
Mass 301 redirect in htaccess
I use ScreamingFrog to generate sitemaps for my Magento 2 multistore, but I recently noticed two issues. Each category/page has two URLs. One with / and the end and one without. Every product has two URLs. One with /product-name and the other /shop/product-name. The URLs are canonicalised, but this is still a problem and I'm not sure exactly how to execute this in the htaccess file. So I need to: Remove all URLs without the / at the end and redirect them all to the URL with / at the end. Or vice versa. 301 redirect every single product (there are over 400) from shop/product-name to /product-name. How do I do this en mass in the htaccess file?
Intermediate & Advanced SEO | | moon-boots0 -
URL indexed but not submitted in sitemap, however the URL is in the sitemap
Dear Community, I have the following problem and would be super helpful if you guys would be able to help. Cheers Symptoms : On the search console, Google says that some of our old URLs are indexed but not submitted in sitemap However, those URLs are in the sitemap Also the sitemap as been successfully submitted. No error message Potential explanation : We have an automatic cache clearing process within the company once a day. In the sitemap, we use this as last modification date. Let's imagine url www.example.com/hello was modified last time in 2017. But because the cache is cleared daily, in the sitemap we will have last modified : yesterday, even if the content of the page did not changed since 2017. We have a Z after sitemap time, can it be that the bot does not understands the time format ? We have in the sitemap only http URL. And our HTTPS URLs are not in the sitemap What do you think?
Intermediate & Advanced SEO | | ZozoMe0 -
Temporarily redirecting a small website to a specific url of another website
Hi, I would like to redirect a small website that contains info about a specific project temporarily to a specific url about this project on my main website. Reason for this is that the small website doesn't contain accurate info anymore. We will adapt the content in the next few weeks and then remove the redirect again. Should I set up a 301 or a 302? Thanks
Intermediate & Advanced SEO | | Mat_C1 -
Should I do a redirect
Hello, I am building a new website with a new web address for subpages. The domain name stays the same. I am wondering if I should do redirect to the few pages that have an outside link going to them. I noticed all my subpage that don't have any external link have an authority of 18. I only have 1 subpage that has 2 external links and 1 of them has a spam score of 32 and then other one of 1. My website is about a 100 pages. What should I do for my subpages redirect , not redirect, redirect only the ones that have external links ? Thank you,
Intermediate & Advanced SEO | | seoanalytics0 -
How Does Yelp Create URLs?
Hi all, How does Yelp (or other sites) go about creating URLs for just about every service and city possible ending with the search? in the URL like this https://www.yelp.com/search?cflt=chiropractors&find_loc=West+Palm+Beach%2C+FL. They clearly aren't creating all of these pages, so how do you go about setting a meta title/optimization formula that allows these pages to exist AND to be crawled by search engines and indexed?
Intermediate & Advanced SEO | | RickyShockley0 -
Changing URL to a subdomain?
Hi there, I had a website www.footballshirtcollective.com that has been live since July. It contains both content and eCommerce. I am now separating out the content so that; 1. The master domain is www.footballshirtcollective.com (content) pointing to a new site 2. Subdomain is store.footballshirtcollective.com (ecommerce) - pointing to the existing site. What do you advise I can do to minimise the impact on my search? Many thanks Mike
Intermediate & Advanced SEO | | mjmaxwell0 -
301 redirect help
Hey guys, I normally work in WordPress and just use a 301 redirect plugin. I bought a site and rather than maintain two similar ones have decided to redirect one to the other. I am having trouble with the .htaccess file. Here is an example. These are two redirects: redirect 301 /category/models/next/2
Intermediate & Advanced SEO | | DanDeceuster
redirect 301 /category/models I want both of these URLs to redirect to the same URL of the new site. However, the /category/models is the only one working. It redirects to the new page just fine. The /category/models/next/2 is redirecting to nearly the same URL on the new site, only it is adding /next/2 to the end and that is bringing up a 404. Why is it adding /next/2 to the new URL? How can I fix this? There are several doing this. Help appreciated!0 -
How do I set up a 301 redirect if the default settings for our web servers create multiple URLs for the same page?
How do I set up a 301 redirect if the default settings for our web servers create multiple URLs for the same page but only views it as one page?
Intermediate & Advanced SEO | | ibex0