Mobile app version of vmapp.org
Login or Join
Bethany197

: Redirect 301 directive for Apache Sub directory and query string combining issue I am getting 404 errors in google console. Some thing like this http://www.example.com/newsite12121212121212/eg/st_tour/perma/

@Bethany197

Posted in: #301Redirect #Htaccess #Redirects

I am getting 404 errors in google console. Some thing like this
www.example.com/newsite12121212121212/eg/st_tour/perma/ http://www.example.com/newsite12121212121212/eg/st_activity/extreme-biking/ www.example.com/newsite12121212121212/eg/st_activity/extreme-biking/?currency=EUR http://www.example.com/newsite12121212121212/eg/st_rental/new/?currency=EUR www.example.com/eg-login/?location_id=1680&s=France&currency=ALL&orderby=price_desc

I want to redirect all of these on the home page of my site as they pages did not exists.

Problem # 1: I want to move any page that is under /newsite12121212121212/ or any of sub directory to home page no matter what is offer that, its may be a file or a sub directory.

Problem # 2: ?currency= some thing, take it back to home page. I tried

RewriteEngine On
RewriteCond %{QUERY_STRING} ^currency=$
RewriteRule ^$ www.example.com/? [R=301,L]


Its working for the www.example.com?currency=EUR but fails on www.example.com/eg-login/?currency=EUR.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Bethany197

1 Comments

Sorted by latest first Latest Oldest Best

 

@BetL925

If you want to redirect any page to the home page when it has a currency parameter, you have to change your regular expression that matches the path portion. Currently you are trying to use ^$ which matches an empty path. .* would match "any path":

RewriteEngine On
RewriteCond %{QUERY_STRING} ^currency=$
RewriteRule .* www.example.com/ [R=301,L]


You could have another rewrite rule that for the directory:

RewriteRule /?newsite12121212121212.* www.example.com/ [R=301,L]


As we have said in the comments, it isn't good for SEO to redirect to the home page. Google considers home page redirect to be "soft 404" errors. It will treat them as if you return "404 Page Not Found" status. Redirecting to the home page won't make the errors in Google Search Console go away.

If you actually have a page for st_tour/perma, you should redirect to it instead of the home page. It might require more redirect rules, but both users and search engines will be happier.

If you have never had such a page, then don't try to claim the URL. It may be caused by spam, malware, or a previous spammy site running on your domain name. If you claim those URLs you could be inviting penalties from search engines. Having 404 errors in your crawl report on Google Search Console for pages that shouldn't exist won't hurt your site in any way. John Mueller from Google says so here: plus.google.com/+JohnMueller/posts/RMjFPCSs5fm

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme