Htaccess issue
-
I have some urls in my site due to a rating counter. These are like:
domain.com/?score=4&rew=25
domain.com/?score=1&rew=28
domain.com/?score=5&rew=95These are all duplicate content to my homepage and I want to 301 redirect them there. I tried so far:
RedirectMatch 301 /[a-z]score[a-z] http://domain.com
RedirectMatch 301 /.score. http://domain.com
RedirectMatch 301 /^score$.* http://domain.com
RedirectMatch 301 /.^score$.* http://domain.com
RedirectMatch 301 /[a-z]score[a-z] http://domain.com
RedirectMatch 301 score http://domain.com
RedirectMatch 301 /[.]score[.] http://domain.com
RedirectMatch 301 /[.]score[.] http://domain.com
RedirectMatch 301 /[a-z,0-9]score[a-z,0-9] http://domain.com
RedirectMatch 301 /[a-z,0-9,=,&]score[a-z,0-9,=,&] http://domain.com
RedirectMatch 301 /[a-z,0-9,=&?/.]score[a-z,0-9,=&] http://domain.comNone of them works. Anybody? Solution? Would be very much appriciated
-
This is the document I was searching for. I always got lost as other resources did not explain all character means but I think I will at last be able to understand this one. Thanks again
-
Thanks again for your help, really, much appreciated. Have a nice day.
-
Can I suggest that you read through the docs? They're pretty good and have some nice intros:
http://httpd.apache.org/docs/current/rewrite/
http://httpd.apache.org/docs/current/rewrite/intro.html
% needed since it is a variable
^(.*)$ is 'match the url'
? at the end deletes the query string that came in.
Note, the ^(.*)$ is calculated first, then the condition.
So the whole thing says:
^(.*)$ .... for any urls,
RewriteCond.... where there is a query string with score, rel etc.http://domain.com? .... replace the whole thing with http://domain.com/
-
Can I ask you two more things?
First, could you please explain the regex to me as I don't understand a few parts, so:
RewriteCond %{QUERY_STRING} ^score=[0-9]&rew=[0-9]$
RewriteCond this is the condition hen rewrite should take place
% I don't know why it is necessarry just see it everywhere
{QUERY_STRING} gets the query string
^ matches from beginning
score=[0-9]* score=takes a number from 0-9 zero to more times
&rew=[0-9]*$ again with rew=RewriteRule rule fot the rewrite
^(.*)$ I totally don't get this one
http://domain.com? I don't know why ? is needed
[R=301,L] 301 redirectSecondly I would like to ask you for a code to remove .html endings from any urls.I think it should begin like
RewriteCond %{QUERY_STRING} (.*).html
But I am totally not enough for the second part. Could you please help me with this one as well?
-
Happy to help Zsolt, I know how frustrating it can be to get some rules working.
Here's a great place to test regex: http://gskinner.com/RegExr/
-
Splendid You are the MAN. Thanks
-
Try playing with something like this:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} ^score=[0-9]&rew=[0-9]$
RewriteRule ^(.*)$ http://domain.com? [R=301,L]The score part of the URL are being treated as parameters.
An alternative would be (in GWT and BWC) to tell Google/Bing to ignore the score and rew parameters
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
-
Set Up htaccess File
Looking for expert help (willing to pay) to set up a proper htaccess file. I'm having an issue as the site has a subdomain at secure.domain.com and has php extensions there. I tried a couple recommended code sets but it seems to be a mess. The site is working properly but this may be causing rankings issues. It's coded in pure HTML and PHP, no Wordpress stuff.
Technical SEO | | execubob
The delete www causes the secure side to fail. The delete html extensions causes the php extensions to fail.0 -
Google Search Console - URL Parameters Tab ISSUE
Hi, Recently i removed some disallowed parameters from my robots.txt and added the setting No Url in my search console URL parameters tab (as can be seen in the image http://prntscr.com/e997o5) Today i saw the orderby parameter indexed even if the setting is to not crawl those urls. Anyone any idea why is this happening? Thank god that all those urls with parameters are canonicalised to their original url's.
Technical SEO | | dos06590 -
Duplicate content issues arise 6 months after creation of website?!
Hi, I've had the same website for 6 months and fixed all original on-site issues a long time ago.Now this week I wake up and found 3 new errors: 3 of my pages have missing titles issues, missing meta description issues and also the Moz crawl says they all have duplicate content issues. All my rankings went down a lot as well. This site is static, doesn't even have a blog, everything is rel canonical and non-indexed. It's 100% original content as well. So how can those issues arise 6 months later? All my titles and descriptions are there and non-duplicate, and the content is original and not duplicate as well. Is this a wordpress bug or virus? Anyone had this happen to them and how to fix it? Thanks a lot for you help! -Marc
Technical SEO | | marcandre0 -
Most common SEO issues with Magento
Which issues does Magento provide out of the box, what should i be aware of? What would you recommend to change/fix as soon as possible?
Technical SEO | | Mickelp0 -
Squarespace Duplicate Content Issues
My site is built through squarespace and when I ran the campaign in SEOmoz...its come up with all these errors saying duplicate content and duplicate page title for my blog portion. I've heard that canonical tags help with this but with squarespace its hard to add code to page level...only site wide is possible. Was curious if there's someone experienced in squarespace and SEO out there that can give some suggestions on how to resolve this problem? thanks
Technical SEO | | cmjolley0 -
SEO-MOZ bar question on root vs subdomain / canonicalization issues
When I look at the SEO-MOZ bar for our site and click next to subdomain (# links from #domains) it shows my main incoming links etc. but when I click on root domain ity shows mydomain/default.asp and 4 incoming links as well as a message that says this url redirects to another url. Does this imply canonicalization issues or is there a 301 redirect to my non /default.asp correcting this issue. Thanks kindly, Howard
Technical SEO | | mrkingsley0 -
Javascript or HTML / DIVS to fix pagination issues?
Which is better to fix a pagination problem, javascript or HTML/DIVs? I know in one Google Webmaster Forum, a Google engineer recommends Javascript, but I've also seen people use DIVs.
Technical SEO | | nicole.healthline0 -
301 redirect .htaccess problem
Can anyone explain to me why this doesn't work? Redirect 301 /category/diamond-pendants/nstart/1/start/(.*) http://www.povada.com/category/pendants/nstart/1/start/$1 Im trying to replace everything after /start/ and insert it into the new url. Thanks in advance.
Technical SEO | | 13375auc30