Page 1 of 1
cannot htaccess 301 redirect, with pretty urls enabled
Posted: Fri Jan 31, 2014 2:05 pm
by davidhans
Hi all. I enabled pretty urls and it works great. However, I still get search traffic going to the old urls (;
http://www.mysite.co.uk/index.php?page=who) and google sitemaps is throwing up a duplicate title tags issue (its treating the two urls as separate pages. So I wanted to force queries to resolve to the new urls using htaccess file.
Conventional "Redirect 301 /index.php?page=who ;
http://www.mysite.com/who.html" does not work. The closest I've got is:
RewriteCond %{QUERY_STRING} ^page=who$
RewriteRule ^index.php$ who.html [R=301,L]
But that resolves to:
http://www.mysite.com/who.html?page=who
Apart from that amend I'm using the standard htaccess file form latest version of cmsms.
Can anyone help? Thanks
Re: cannot htaccess 301 redirect, with pretty urls enabled
Posted: Fri Jan 31, 2014 2:11 pm
by Rolf
Re: cannot htaccess 301 redirect, with pretty urls enabled
Posted: Fri Jan 31, 2014 3:12 pm
by velden
It's all about canonical urls.
You should NOT 301 those requests. Google for 'canonical url' and look at some sample templates. Use that to tell Google and frieds what url they should index.
Re: cannot htaccess 301 redirect, with pretty urls enabled
Posted: Fri Jan 31, 2014 5:59 pm
by JohnnyB
However, I still get search traffic going to the old urls (;
http://www.mysite.co.uk/index.php?page=who) and google sitemaps is throwing up a duplicate title tags issue (its treating the two urls as separate pages.
Since Google has already indexed your old URLs using the page= query, you can tell Google in your Webmasters account do not index query strings.
Also in your robots.txt file, you can try adding something like:
Disallow: /index.php?page
Re: cannot htaccess 301 redirect, with pretty urls enabled
Posted: Mon Feb 03, 2014 9:58 am
by davidhans
Hi guys. Thanks for the replys. I think I'll use webmasters tools to specify the preffered urls, as you suggested. Rolf, thanks for the link, but this was the first place I went to when I was searching for a solution. I could not get any of the four rewrites to work:
RewriteRule ^old/path/to/something.html$ ;
http://www.website.com/new/path/to/something [R=301,L]
RewriteRule ^something$ ;
http://www.website.com/something [R=301,L]
RewriteRule ^something/$ ;
http://www.website.com/something/ [R=301,L]
RewriteRule something.html$ ;
http://www.website.com/something [R=301,L]
I wondered if one of the characters in my string was interfering and needed to be escaped (the above examples are all simple .html files). I tried things like:
RewriteRule ^index.php?page=who$ ;
http://www.website.com/who.html [R=301,L]
Should this have worked?
Re: cannot htaccess 301 redirect, with pretty urls enabled
Posted: Mon Feb 03, 2014 10:04 am
by velden
Actually a dot should be escaped. But it will work anyway because it stands for 'any character'.
But again: you probably don't want this. I'm not sure if you wouldn't generate an endless loop this way. In the end, cmsms needs the 'index.php?page=who'