views:

21

answers:

1

hi all, I need ur help for given subject. I am playing with htaccess rules first time in life.

here is the scene -

i want to redirect the urls -

 http://www.abc.com/var1
 http://www.abc.com/var2

to follwing urls -

 http://www.abc.com/index.php?u=var1
 http://www.abc.com/index.php?u=var2

In this case the values var1 & var2 can be anything (i.e. string which will contain only alphanumeric characters.)

One more thing -

I want to skip this rule if the url is -

http://www.abc.com/SKIPME

Please help me to write this rule!

Regards, Shahu!

A: 

You would be better off defining a URI schema that tells you when something WILL be rewritten. For example...

 http://www.abc.com/site/var1
 http://www.abc.com/site/var2

That way, you can ensure you only ever apply the rule if the psuedo "site/" directory is browsed and not affect any other URI. This is the rewrite rule based on the above schema.

RewriteEngine on
RewriteRule ^site/([^/\.]+)/?$ index.php?u=$1 [L,NC,QSA]

Any other address, other than "/site/.../" would be unaffected by this rule, which means you don't need to worry about setting some addresses to be avoided. This keeps things as simple as possible.

You don't have to use "site" - you can use whatever name fits your purpose.

Sohnee
sounds good let me try this one!
thanks a lot!! you save my time!!