Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    CBG
    CBG is offline
    New Coder
    Join Date
    Feb 2010
    Location
    UK
    Posts
    91
    Thanks
    26
    Thanked 0 Times in 0 Posts

    Question [SOLVED] htaccess rewrite old to new URL - Old URL is index.php?page=

    Hi,

    I would like to rewite the following using .htaccess

    From: index.php?page=allnews
    To: news.php

    But sometimes the from is like: index.php?page=allnews&results_per_page=20
    I am not wanting the &results_per_page=20 bit put on to the new URL.

    I have tried:
    RewriteRule ^/index.php?{%QUERY_STRING}&page=allnews$ news.php [R=301,L]

    Also tried using cPanel redirect system, but it wasn't including the ?page= bit so it was redirecting the index.php which I don't want.

    Can anyone help please?
    Thanks
    Last edited by CBG; 04-22-2011 at 01:47 PM.
    Regards,
    CBG

  • #2
    CBG
    CBG is offline
    New Coder
    Join Date
    Feb 2010
    Location
    UK
    Posts
    91
    Thanks
    26
    Thanked 0 Times in 0 Posts
    I have just tried

    Code:
    RewriteCond %{QUERY_STRING} page=allnews
    RewriteRule ^index.php$ news.php [R=301,L]
    The problem with this the URL it is: news.php?page=allnews
    I am wanting to strip everything after news.php in the rule
    Regards,
    CBG

  • #3
    CBG
    CBG is offline
    New Coder
    Join Date
    Feb 2010
    Location
    UK
    Posts
    91
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Hi,

    Have got it now, it was all in a ? (question mark)
    Code:
    RewriteCond %{QUERY_STRING} page=allnews
    RewriteRule ^index.php$ news.php? [R=301,L]
    Regards,
    CBG


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •