1

I have some dupilcate pages in my Joomla site.

Examples

/80-games

/80-games?start=12

/80-games?start=20

I did a 301 redirect in my .htcaccess for the first one which works fine.

My redirect for /80-games

    Redirect 301 /80-games http://www.teach-this.com/esl-games

But for /80-games?start=12

The url changes to http://www.teach-this.com/esl-games?start=12

What should my redirect be for /80-games?start=12

Somehow the question mark is causing my destination url to change.

Thanks

Paul

  • the ? is the start of parameters given to the webserver (get method). It is actually not part of the URL and therefore, also passed along to the new URL. – Lexib0y Jan 06 '14 at 10:24
  • Check these posts: http://stackoverflow.com/questions/10726439/remove-query-string-during-a-301-redirect and http://stackoverflow.com/questions/3457022/mod-rewrite-remove-query-string-from-url – Lexib0y Jan 06 '14 at 10:25
  • Thanks for the links, I tried the answers suggested but they didnt work. – user3160546 Jan 06 '14 at 11:09

1 Answers1

1

You should use mod_rewrite as you cannot manipulate QUERY_STRING using mod_alias rules.

Put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On
RewriteRule ^80-games/?$ http://www.teach-this.com/esl-games? [R=301,L,NC]

Note ? at the end of target URI that is used to strip out any existing QUERY_STRING in the original URL.

anubhava
  • 761,203
  • 64
  • 569
  • 643
  • I added the code under ## Mod_rewrite in use. in my Joomla .htcaccess but the problem didnt go away. Any ideas? – user3160546 Jan 06 '14 at 11:08
  • 1
    Make sure this is **first rule** in your .htaccess AND test it in a different browser to avoid 301 caching issues. Also make sure rule has `http://www.teach-this.com/esl-games?` with `?` in the end. – anubhava Jan 06 '14 at 11:11
  • 1
    You're a star! I put them as the first rule and it worked straight away. Thanks very much. – user3160546 Jan 06 '14 at 11:28
  • Thanks again. I saw one of the duplicate pages is just marked as / How should I redirect that? Or is that a new thread? – user3160546 Jan 06 '14 at 11:38
  • Yes please create a new question with little more details. I will try to answer if I can. – anubhava Jan 06 '14 at 11:39