File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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.
I agree. Here's the link:
subject: Use htaccess to implement pretty URL