.htaccess...For the life of me I just can't get this to work

Hope someone could help, basically I just needed the following condition

if user access url http://www.example.com/article/jhfjjvr

i needed it to redirect to the article folder like so: article/index.php?path=jhfjjvr

Other than anything else like

http://www.example.com/blah/
http://www.example.com/hello
http://www.example.com/whatever

I need it to redirect to

public/index.php?path=blah
public/index.php?path=hello
public/index.php?path=whatever

What I’ve tried:

RewriteCond $1 ^article(.*)$
RewriteRule ^article(.*)$ article/index.php?path=$1 [PT,L]

RewriteCond $1 !^article
RewriteRule ^(.*)$ public/index.php?path=$1 [L]

Is the above condition correct??

js,

Specificity:

Case 1: article/{whatever} => article/index.php?path={whatever}

Case 2: {not_article/} => index.php?path={not_article}

If you notice, both {whatever} and {not_article/} CONTAIN the redirection, too, so care must be taken to EXCLUDE the index.php in both instances. This would be easiest if I can assume that {whatever} and {not_article/} are ONLY lowercase letters (NO dot characters) so that’s what I’ll do rather than create a PROPER RewriteCond (please look to the examples in my signature’s tutorial Article for that).

RewriteCond $1 ^article(.*)$
RewriteRule ^article(.*)$ article/index.php?path=$1 [PT,L]
# Passthrough?  :nono:
# Loops on /index.php
# Do you really want the / in the path value?

RewriteCond $1 !^article
RewriteRule ^(.*)$ public/index.php?path=$1 [L]
# loops on  public/index.php

Okay, at noted above, the RewriteConds are incorrect (not to mention the first one’s flag).

What I would have used (with the simple assumption made above, i.e., that the variables you are using do NOT contain the dot character - add to that the / character for the public one):

RewriteEngine on
RewriteRule ^article/([^.]+)$ article/index.php?path=$1 [L]

RewriteRule ([^/.]+)$ public/index.php?path=$1 [L]

If you REALLY need the dot character in either/both and the / character in the public RewriteRule, then I’d use:

RewriteEngine on
RewriteCond $1 !^index\\.php$
RewriteRule ^article/(.+)$ article/index.php?path=$1 [L]

RewriteCond $1 !^public/index\\.php$
RewriteRule (.+)$ public/index.php?path=$1 [L]

Normally, the RewriteCond must have a variable but you’ve taken care of that by using the atom from their RewriteRules (which is quite legal!) but checked that it NOT match the redirection in both cases (the article/ was NOT included in the first’s atom).

Questions?

Regards,

DK

wow very much thanks for the great help dklynn! I have to try it out though it seems like my way of doing things over complicate stuff. Really your help!!!