-3

I need all pages on my site to be redirected to home.php with query string and the page as parameter

examples:

   www.site.com/abcd
-> www.site.com/home.php?page=abcd

   www.site.com/abcd/file.php
-> www.site.com/home.php?page=abcd/file.php

   www.site.com/file.php?a=b&c=d
-> www.site.com/home.php?page=file.php&args="a=b&c=d"
AndrewC
  • 32,300
  • 7
  • 79
  • 115
user1663047
  • 107
  • 1
  • 8

1 Answers1

2

You could put this in your .htaccess file:

RewriteEngine On
RewriteRule ^(.+)$ home.php?page=$1 [QSA,L]

This will do what you want, except for the parameters passed, they will show up in there original form:

www.site.com/file.php?a=b&c=d -> www.site.com/home.php?page=file.php&a=b&c=d
JvdBerg
  • 21,777
  • 8
  • 38
  • 55
  • thanks, and FYI I figured out how to parse the parameters in PHP: $args = '?'; foreach ($_GET as $g => $g2) { if ($g<>"page") {$args .= $g."=".$g2."&";} } $args = substr($args,0,-1); – user1663047 Sep 22 '12 at 14:12