Page 1 of 1

Using mod_rewrite

Posted: Wed Feb 13, 2008 10:58 am
by aceconcepts
Hi,

I now understand mod_rewrite to a greater extent.

However, I was wondering if anyone could tell me how to re-write my rule so that i can simply declar my variable straight after the domain name

e.g.

What I want to do is re-write: http://www.site.com/registration - where registration would be a variable

At the moment I have to write it like this: http://www.site.com/index/registration - I basically want to get rid of "index".

Here is my rule: RewriteRule (.*)//(.*) $1.php?parameters=$2

Thanks.

Re: Using mod_rewrite

Posted: Wed Feb 13, 2008 11:03 am
by Zoxive
Most common way to rewrite is done with the following

Code: Select all

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
 
RewriteRule ^(.*)$ index.php/$1 [L]
Rewrites everything to index, then the Front Controller would decide how to set everything.

To answer your question though..

Code: Select all

RewriteRule ([^/]*)$ index.php?param=$1
Matches everything but the /'s