By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,230 Members | 2,471 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,230 IT Pros & Developers. It's quick & easy.

allow access to folders in spite of mod_rewrite

P: 14
Hi,

I'm currently using mod_rewrite to rewrite URLs with server variables.

Expand|Select|Wrap|Line Numbers
  1.     RewriteEngine on
  2.  
  3.         RewriteRule ^([A-Za-z0-9-_]+)$ /layout4/$1/ [R]
  4.             RewriteRule ^([A-Za-z0-9-_]+)/?$ index.php?dir=&page=$1
  5.         RewriteRule ^([A-Za-z0-9-_/]+)/([A-Za-z0-9-_]+)$ /layout4/$1/$2/ [R]
  6.             RewriteRule ^([A-Za-z0-9-_/]+)/([A-Za-z0-9-_]+)/?$ index.php?dir=$1&page=$2
where $dir is the directory path and $page is the filename

What I'd like to do is somehow enable visitors to actually open a folder. ie. I have a folder http://localhost/layout4/discography, but when I type that in, mod_rewrite thinks that its a query of a sort and doesn't lead to the folder discography or rather, discography/index.php. What should I do? Or is the better way to simply not use index.php and redirect http://localhost/layout4/discography to something like http://localhost/layout4/discography/main.php?

Thanks y'all! :D
Jun 3 '07 #1
Share this Question
Share on Google+
1 Reply


Motoma
Expert 2.5K+
P: 3,235
The safest way to do this would be to create a script to show your user the directory.
That way discography/ would really be discography/index.php, but the user would not know the difference.
Jun 6 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.