views:

43

answers:

1

I have a directory structure with the following on localhost:

http://localhost/testing/

A directory structure exists inside of testing as follows:

/testing/public
/testing/public/index.php
/testing/public/img
/testing/public/css
..etc for the js and swf directories

A .htaccess file is inside the testing folder and the contents are as follows:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /testing/

RewriteRule ^public$ public/ [R,QSA]
RewriteRule ^public/$ public/index.php?state=public [L,QSA]

RewriteRule ^stackoverflow$ stackoverflow/ [R,QSA]
RewriteRule ^stackoverflow/$ public/index.php?state=stackoverflow[L,QSA]

I am using PHP and inside of the /testing/public/index.php file I wanted to test that the $_GET['state'] is indeed saving the variable.

When I try to test out:

http://localhost/testing/public

$_GET['state'] is not found at all BUT

http://localhost/testing/stackoverflow

does indeed echo out that $_GET['state'] equals 'stackoverflow'.

What am I missing here??? Why is it that I cannot get the state=public in the first link? Thanks for the help!

+1  A: 

This works fine on my system, but I think you are getting into trouble by having a rewrite rule with the same name as an actual file system directory. The file-system will generally take precedence. So when you load up '/testing/public' it just loads /testing/public/index.php without running your rule at all.

Try changing the rule to this:

RewriteRule ^public_$ public_/ [R,QSA]
RewriteRule ^public_/$ public/index.php?state=public [L,QSA]

Navigate to 'testing/public_', if that prints out 'public' as expected then you will know that was your problem.

Nathan Reed
You are right with what you said, it did take precedence! Finally I can sleep with a sane mind...haha. Thanks Nathan. I changed the name of the directory completely to 'public_content' to avoid it completely. Again thank you!
ninumedia