doubledee Posted December 31, 2011 Share Posted December 31, 2011 This past Summer I had some help creating my first ever Mod_Rewrite so I could have "Pretty URLs" in my website! After several months away from the code, I would like to get some help making sure that I understand how things really work!! Here is my Mod_Rewrite... RewriteEngine on #PRETTY: articles/postage-meters-can-save-you-money #UGLY: article.php?title=postage-meters-can-save-you-money RewriteRule articles/([a-zA-Z0-9_-]+)$ article.php?title=$1 This is my understanding of how things work, but please correct me if I am wrong!! 1.) A user clicks on the hyperlink www.MySite.com/articles/postage-meters-can-save-you-money 2.) Apache intercepts that URL and uses the Mod_Rewrite to transform things. Specifically, the Mod_Rewrite converts my "Pretty URL" above to the following "Ugly URL" format... www.MySite.com/article.php?title=postage-meters-can-save-you-money 3.) From this point forward, the Browser and my PHP script will always be working with the "Ugly URL"... www.MySite.com/article.php?title=postage-meters-can-save-you-money 4.) But to the user, they will always see the "Pretty URL"... www.MySite.com/articles/postage-meters-can-save-you-money So if my PHP article template wants to display the article, it will need to use... ($_GET['title']) ...to locate the article in the transformed URL and then query MySQL to find said article. Does all of the above sound correct or not? Thanks, Debbie Link to comment https://forums.phpfreaks.com/topic/254114-how-does-a-mod_rewrite-really-work/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.