I'm using WAMP to serve a pet project on my localhost called "mvc." I'm trying to redirect requests made to mvc's root to a sub folder called /public. I have a .htaccess file in my root with the below code. It's not getting the job done.

I'm using WAMP to serve a pet project on my localhost called "mvc." I'm trying to redirect requests made to mvc's root to a sub folder called /public. I have a .htaccess file in my root with the below code. It's not getting the job done.

#!-f .htaccess ignores all requests made to specific files within directoryRewriteCond %{REQUEST_FILENAME} !-f

#favicon.ico is a default file some browsers request. don't let browser trigger 404 if we don't have this fileRewriteCond %{REQUEST_URI} !=/favicon\.ico

# technique?

RewriteBase /mvc/public

#send all alphanumeric requests to index.php as QSA, second match catches file extensionRewriteRule ^([-_A-z0-9\/]+)\.?([A-z]+)?$ /mvc/public/index.php?url=$1&extension=$2 [QSA,L][indent]# Really, from A (character 41) to a (character 7a)?

[A-z] is shorthand for [A-Za-z] which works just as well and makes your code more readable. About the extension being optional, this is correct. I'm bootstrapping everything through the directory's index.php file.

It may not have been the cause of your problem, but I think this trick is actually bad practice, because it deceptively includes characters you may not have intended, such as [ \ ] ^ _ `

I wasn't aware of this. Thank you for pointing that out.

Your directory tree is correct. That is how I have my project set up. After stating you were able to run the script successfully, I had to ensure mod_rewrite was in fact enabled. It is. The rewrite_module is being loaded and the AllowOverride rules are set accordingly.

If anything, thank you at least for pointing out the specifics with the regex flaw. That may be the most important thing I learn all day!