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
-
Does using a canonical with ?utm_source=gmb cause any issues?
All of our URLs in Google My Business are tagged with ?utm_source=gmb. This way when people click on it within a Google Map listing, knowledge graph, etc we know it came from there. I'm assuming using a canonical on all ?_utm_source _pages (we have others, including some in the index) won't cause any problems with this, correct? Since they're not technically traditional organic SERPs? Dumb question I know, but better safe than sorry. Thanks.
Technical SEO | | Alces1 -
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 -
Mobile and hidden content - Any issue for SEO?
In reference to mobile - am I walking a fine SEO line when it comes to hidden content on mobile? On the responsive variations of sites we are working on some content is hidden (that displays on the desktop version of the site) so that pages on mobile can display correctly. Is this negative for SEO? Appreciate any feedback Cheers.
Technical SEO | | Oxfordcomma0 -
Htaccess redirect with question mark
Hi I have a problem setting up my htaccess for a specific page that has a question mark in the link, and one that has a space in the link and also a question mark. So I would like 2 redirects in my htaccess like that: www.olddomain.com/page.php?page=pagename1 to www.newdomain.com/newpage1.html www.olddomain.com/page.php?page=page name2 to www.newdomain.com/newpage2.html I have tried with something like this but doesn't work: RewriteEngine on RewriteRule ^page.php?page=pagename1 "http://www.newdomain.com/newpage1.html" [R=301,L] RewriteRule ^page.php?page=page name2 "http://www.newdomain.com/newpage2.html" [R=301,L] Could someone tell me what exactly I have to change? Thanks
Technical SEO | | darkanweb0 -
Can these Yoast SEO integration issued be solved?
I had a site analysis done by the Yoast team. Of course, one of their recommendations was to install the Yoast SEO product. I see that there are many independent sources highly recommending it. But my programming is coming back with some concerns. My website is www.heartspm.com, for anyone who is interested in further analysis of my issue. My programmer's notes follow. Unfortunately, they are a bit to cryptic: "1. it does not do all for us anyway, so we'd have to keep the one's I made
Technical SEO | | GerryWeitz
before anyway, at least partially, but it will add up to complexety, loading
time as all new, and especially one-size-fits all plugins 2. another problem - Simple Press forum. Yoast does not have an extention for it, nor is it going to work along with our existing forum's SEO handling solution. So, it's
either reverting back to original SEO handling or forgetting Yoast. 3. original handling means no meta description although I think Yoast will put just
one description for each page, and title will be something like "<forum <br="">title> - <topic title="">whatever else you may want" 4. the same thing with XML sitemap 5. we won't be able to use Yoast's because it won't handle cities 6. and hopefully it will work with our existing XML sitemap solution as this can be turned off" Now, The Yoast team admitted and logically said that the Yoast plugin cannot support another plugin and therefore it does not support forums. We currently integrate the forum into our Wordpress site and perhaps imperfectly, but we are able to append forum links to the xml sitemap. Do any of you have insight into how one incorporates a forum into a Wordpress blog while using Yoast SEO?</topic></forum> We have special parameter based handling of cities. We used to pass codes like city=?zip and the like. Now, the URLS are very clean looking, but they use templates to match up cities in a city table with content that is somewhat similar, yet customizable. So my programmer seems to be saying that the Yoast tool doesn't seem to handle templates well or is not able to interpret it and get it into a sitemap. Do any of you have insight into using Yoast SEO with Wordpress sites that use templates and variables for locals or something of a similar nature? The Yoast SEO module also has switches to help resolve issues with duplicate content and archives and authors and multiple pages, i.e. page 1-10 of Latest News. If I can't use the whole Yoast module, are there ways to use only parts of it or to strip it down to what I want? Do you think with the above considerations, that the Yoast SEO module is not worth the trouble? Thanks in advance, Humbly, Gerry0 -
Do I need a 301 redirect on htaccess if Apache is already configured to serve?
Apache is set up to serve both www and non-www versions the same content. Do I still need to put a 301 redirect in the htaccess file?
Technical SEO | | Ocularis0 -
301 redirect Issues
my clients site is www.greenbayharvest.co.uk When you enter that URL it redirects to www.greenbayharvest.co.uk/shop, dont ask why, thats the way they set it up and thats what im stuck with. So, how do i resolve the 301 issue here. we want all things to point to www.greenbayharvest.co.uk, in terms of SEO but does the fact that there is a redirect going to /shop make this an issue? we appear to have: www.greenbayharvest.co.uk/shop www.greenbayharvest.co.uk greenbayharvest.co.uk greenbayharvest.co.uk/shop all these URL's go to the same same page so what is the best way to correct this? thanks for any help on this Lee
Technical SEO | | IPIM0 -
Re-direct issues
Forgive me for the novice question. But I was recently looking at open site explorer and was checking out my site www.visualawards.com , I know we have a re-direct to www.visualawards.com/home.php . After checking both URL's, I found that I have links pointing to both. Is this bad, am I diluting the links? If yes, which one should I point the future ones to, and is there anyway to recover the current links already? Thanks again for your help!!!
Technical SEO | | RENDEV0