Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use htaccess to implement pretty URL

 
Hikari Shidou
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic