This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes PHP and the fly likes Use htaccess to implement pretty URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Languages » PHP
Bookmark "Use htaccess to implement pretty URL" Watch "Use htaccess to implement pretty URL" New topic

Use htaccess to implement pretty URL

Hikari Shidou
Ranch Hand

Joined: Jan 22, 2013
Posts: 88

I use pretty permalink in Wordpress. Apache's htaccess takes a GET URL like http://domain/path/value1/value2/value3/value4/ and serves it to PHP as something like http://domain/path/index.php?par1=value1&par2=value2&par3=value3&par4=value4

With Wordpress it works fine, but I need to implement it on a raw PHP software, without Wordpress tricks. I googled for a PHP solution and couldn't find one, not even an htacces example that would work without a CMS or framework.

If at least I could receive "/value1/value2/value3/value4/" in PHP I could split it, but not even that I'm able to do. Of course, be able to directly get each variable from $_GET would be better.

The maximum I was able to do was 301 redirect to http://domain/path/index.php?par1=value1&par2=value2&par3=value3&par4=value4 but that's not what I wanna do. I want browser to keep showing http://domain/path/value1/value2/value3/value4/ on address bar.

Could somebody give me hints, on a tutorial or at least a htaccess example?

Note I must be able to set 'domain' and 'path' separately, because the software may be installed on a domain root or inside a folder. And it must always go to index.php.
Don't get me started about those stupid light bulbs.
subject: Use htaccess to implement pretty URL
Similar Threads
How to convert query string into xml Structure
String.split() question
text file extractor
How to Handle Properties
Walk distinct values in xsl key 4 at a time