Using htaccess rewrite/redirect so single PHP file can display data according to GET/POST variables
Posted
by revive
on Stack Overflow
See other posts from Stack Overflow
or by revive
Published on 2010-03-14T04:05:24Z
Indexed on
2010/03/14
4:15 UTC
Read the original article
Hit count: 387
Hey gang,
Bear with me as I try to learn more about .htaccess redirect rules - I'm a UI guy by profession and I'm doing my best to enhance my coding skills languages other than HTML/CSS/PHP, etc
So, what I have is an index.php file that contains a menu - pretty simple. If Javascript is enabled on the users computer then forms are shown below the menu using simple jQuery goodies, with each link having a 'return false;' applied.
What I am trying to do is make the page accessible with JS turned off, so instead of redirecting the user to a different page, I would like to use POST or GET variables from each link, to show the various forms.. within the same index.php file - but have the URL reflect the menu choice
Here is an example using menu items named - Home, About, Form1 and Form2:
With JS on, clicking on of the above example buttons simply slides the form or containing the data down onto the page.
With JS off, if the user clicks the 'About' link, I would like to rewrite the URL to be http://domain.com/about - but keep the user on the index.php page (since it is the only page) and be able to use POST or GET variable to show the using PHP.
So, accessing http://domain.com/index.php?page=about would show http://domain.com/about in the URL but pass the GET variable 'page' to the index.php file.
Hope that makes sense.. and I'm sure there are many ways to accomplish this, so if you have ideas of how to improve on it, by all means, I'd love to hear it !
Thanks again Revive
© Stack Overflow or respective owner