Link to home
Start Free TrialLog in
Avatar of lokeshv
lokeshv

asked on

mod_rewrite question

Hello all

i am using mod_rewrite for rewriting urs

like http://mydomain.com/username

problem is whenever a user enter even valid location on my domain (like images) or any other dir..

which i use for static content..

like http://mydomain.com/statc/

it takes as username also..so how to prevent it ?

i am thinking of to change all dirs names to start with _

so just looking for right .htaccess code to do this..

Thanks in advance
Avatar of blue_hunter
blue_hunter
Flag of Malaysia image

maybe you should tweak a bit

like for user
use
http://mydomain.com/user/username

instead of
http://mydomain.com/username

and in your server configuration, you would take whatever appear after "user/" as the user name.

i believe, this would prevent you to getting "static/" as username too

RewriteEngine On
RewriteRule ^user/([a-z]+)/?$ /usercheck.php?username=$1
RewriteRule ^statc/?$ /statistics.php

Avatar of lokeshv
lokeshv

ASKER

umm

using urls as http://mydomain.com/user/username is certainly not a option...as client doesnt want it ..and application is in last stage.. will have to make lot of changes..

what i am looking for is a regex..for Rewriterule so..part which doesnt start with underscore( _ ) only get rewrited ..

possible ?

Thanks.
Can you post the regex you are currently use?
change the first character of your regex to [^_] this should prevent matching dirs starting with a _
Avatar of lokeshv

ASKER

Hello

hernst42, currently i use this rule

RewriteRule ^(.*)/$ view.php?tid=$1

very simple..not i wann it convert so only dirs which doesnt start with _ should use this rule...

i tired putting  [^_] in start

http://mydomain.com/_lost/ works fine but when i enter

http://mydomain.com/lokesh it cuts the first chracter and send username to 'okesh' to view .php

how to solve it ?

Thanks for help

ASKER CERTIFIED SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lokeshv

ASKER

works great...

Thaks for help...