March 12, 2012

Using .htaccess and mod_rewrite

Question by InVert

I’m having some mod_rewrite problems with my .htaccess..

RewriteBase /folder

RewriteEngine on
Rewrit­eRule ^(.*)$ basic.p­hp?­url=$1 [L]

Above is what I’m current using .. However I have no idea what I’m doing to be honest as I’m just cycling through the internet trying to figure this out.

Basically, for my website, if you type in

“www.domain.com/folder/xxx/”

I want it to basically be “www.domain.com/folder/basic.php?url=xxx”
For some reason, all that does is cause a 404 error :/

So can someone please politely point me in the right direction?

Answer by Starx

Ok, I will explain using your htaccess.

RewriteEngine on

Turn on the Rewrite Module to enable URL rewriting

RewriteBase /folder

Rewrite the Base Directory to directory name folder

RewriteRule ^folder/(.*)$ basic.php?url=$1 [L]

Remap every request make using the folder/***** to basic.php?url=********

Note: RewriteEngine On Should be the first statement on your case

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!