August 03 2009
Screencast 1 – mod_rewrite and PHP
Tagged Under : mod_rewrite, PHP, Screencast, tutorial
Screencast – mod_rewrite and PHP from José Airosa on Vimeo.
Hello folks!
This time, and for the first time, I bring you a screencast! It’s all about mod_rewrite and PHP. What it is, how can we use it and how can we integrate it to be used with PHP.
Below are the functions that i talked about in the screencast. Use them, or not, as you please.
/** * Get current page URL * * @return string with paeg name */ function curPageURL() { $pageURL = 'http'; if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } /** * Get current page script name * * @return string with page script name */ function curPageScriptName() { return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1); } /** * Get current page name * * @return string with page script name */ function curPageName() { return end(explode("/",curPageURL())); } |
Hope you’ll enjoy as much as I did making it
Let me know your feedback.













Thank you so much for this tutorial. I have been seeking top understand mod_rewrite for months now but tutorials I found either just weren’t something I could understand or were not effectively communicated.
My only question is that on urls if I include the forward slash at the end of the url, such as example.com/helloworld/ the html loads but not the css. It all loads fine without the forwardslash at the end. Any idea what I may have done wrong. If I understand correctly, in ^([a-z]*)/?$ the ? says the forwardslash before it can or can not be there. And this is how I have it.
Again, thanks for this awesome tutorial!