cannot htaccess 301 redirect, with pretty urls enabled

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
davidhans
New Member
New Member
Posts: 8
Joined: Wed Sep 12, 2012 11:59 am

cannot htaccess 301 redirect, with pretty urls enabled

Post 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
Last edited by Dr.CSS on Fri Jan 31, 2014 4:21 pm, edited 1 time in total.
Reason: Please use double quotes or something on fake links so they aren't clickable...
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: cannot htaccess 301 redirect, with pretty urls enabled

Post by Rolf »

- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: cannot htaccess 301 redirect, with pretty urls enabled

Post 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.
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm
Location: OH, USA

Re: cannot htaccess 301 redirect, with pretty urls enabled

Post 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
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
davidhans
New Member
New Member
Posts: 8
Joined: Wed Sep 12, 2012 11:59 am

Re: cannot htaccess 301 redirect, with pretty urls enabled

Post 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?
Last edited by Dr.CSS on Mon Feb 03, 2014 4:25 pm, edited 1 time in total.
Reason: Please use double quotes or something on fake links so they aren't clickable...
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: cannot htaccess 301 redirect, with pretty urls enabled

Post 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'
Post Reply

Return to “Modules/Add-Ons”