Web Hosting Talk







View Full Version : Using .httaccess for Virtual Folders? How?


Chris`
07-21-2008, 12:04 AM
Hey folks,

I was just wondering if there's a tutorial or example code I could see about creating virtual folders. Something like using .com/index.php?act=bleh and changing it to just .com/bleh/. I've never done that before, but I am familiar with mod_rewrite, so I just need some code to look at to see how the pro's do it. :stickout:

Could WHT offer me some help? :)
~Chris`

minthu
07-21-2008, 12:35 AM
It is easy, you just have to put only 2 lines in your .htaccess file.

RewriteEngine On
RewriteRule ^(.*)$ index.php?act=$1 [L,QSA]

Chris`
07-21-2008, 01:18 AM
Can you give me an exmaple, using /bleh/ like I posted? Please?

minthu
07-21-2008, 01:22 AM
1. Just paste that 2 lines in your .htaccess file.
2. You should have index.php file to handle further processing.

Put those 2 files under your root directory. You're done. You can type www.yourdomain.com/blah/

Just try it first!

Chris`
07-21-2008, 02:05 AM
Well, I don't want to create a bunch of directories, or is that how you're suppose to do it?

minthu
07-21-2008, 02:07 AM
Try it first. There is no folder creation involved in this simple 2 steps technique.

Chris`
07-22-2008, 06:15 AM
Okay.. Well, how do I create more than one?
Like.. /bleh/ and /blah/ and /bleh-blah/ and each have their own page?

Without creating a bunch of folders?