|
Location: Web development - PHP License: The GNU General Public License (GPL) Friendly URLs without mod_rewritePosted by Giulio BaiFor those who don't want to mess with Apache stuff, here's a quick alternative to mod_rewrite usage |
Skill: BeginnerPosted: 05/12/2008Views: 678Rating: 0.00 /5Popularity: 0.00 |
| Sign Up to vote for this article |
Obtaining nice-looking, search engine-friendly URLs is not that easy, especially when dealing with dynamic content.
A common way to overcome the problem is to use the Apache mod_rewrite. But for those who haven't that particular web server installed or don't want to mess with it (yes, it's not that strightforward as it sounds), here's the quick alternative!
So, we have our nice webpage online at http://example.com/index.php?group=projects&name=myproject&page=7, but we're not happy with it: quite awful uh?
We'd prefer something like http://example.com/index.php/projects/myproject/7
Here we go!
Firstly, we get the current document URL stored in the $_SERVER array.
We then remove the index.php token, replacing it with... well, nothing ('').
The last step is to explode the string so that the stuff we look for ('projects', 'myproject', '7') is all put into our array $vars
Congrats, you have clean URLs now!
This article, along with any associated source code and files, is licensed under The GNU General Public License (GPL)
| Giulio Bai
| Location: |
Sign up to post message on the article message board!