1

How can I make it so that all the old links go to the new url structure?

So navigating to

http://website.com/index.php?page=viewuser.php&userid=1&username=slothinspace

will take me to

http://website.com/viewuser?userid=1&username=slothinspace

I already have the .htaccess changed so that the new URL works, I just want users to be automatically redirected to the new URL if they stumble across the old one.

GalahadXVI
  • 759
  • 1
  • 8
  • 19
  • 1
    Possible duplicate of [.htaccess redirect all pages to new domain](http://stackoverflow.com/questions/1945568/htaccess-redirect-all-pages-to-new-domain) – Matthias W. Jul 13 '16 at 22:15
  • 1
    @matthias-w thats redirecting to a new domain altogether and most of them answers are still using the same query strings. Mine is the same domain and the query strings have changed. I've never used .htaccess so it's a bit of a struggle for me. – GalahadXVI Jul 13 '16 at 22:51

1 Answers1

1

To redirect from

to

add the following rule before your other rules :

RewriteEngine on

RewriteCond %{THE_REQUEST} /index\.php\?page=(.*?)\.php&userid=([^&]+)&username=(.+)\sHTTP [NC]
RewriteRule ^ /index.php?page=%1&userid=%2&username=%3 [L,R]
Amit Verma
  • 40,709
  • 21
  • 93
  • 115