Connecting Tech Pros Worldwide Forums | Help | Site Map

allow access to folders in spite of mod_rewrite

Newbie
 
Join Date: Apr 2007
Location: Sydney
Posts: 14
#1: Jun 3 '07
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
Motoma's Avatar
Moderator
 
Join Date: Jan 2007
Location: Maine, USA
Posts: 2,904
#2: Jun 6 '07

re: allow access to folders in spite of mod_rewrite


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.
Reply