Page 1 of 1

Simple .htaccess

Posted: Mon Jun 25, 2007 9:44 pm
by alex.barylski
Edit: This seems to work, however on directory requests I'm not getting index.php (or default script) - how I add that?

Code: Select all

RewriteEngine on
RewriteBase /

RewriteRule ^(.+)$ index.php?path=$1 [QSA]

Code: Select all

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

#RewriteCond %{REQUEST_FILENAME} [NC]
RewriteRule ^(.+).php$ index.php?page=$1 [QSA]
I borrowed this from CMSMS thinking it should be a simple matter...unfortunately my understanding of regex is not where it could be. :P

All I need it to do is this:

1) When passed a file w/ path I need that path to be passed to index.php (inside docroot).
2) Keep or persist the GP{C} variables so I do not have to parse the URL manually inside script
3) If the requested file already exists, who cares, ignore it and send it's path to index.php instead

Can someone please give me the proper set of instructions to get this fired up?

Thanks :)

Posted: Mon Jun 25, 2007 11:28 pm
by superdezign
What's wrong with what you've got? You're not getting a page at all?

Re: Simple .htaccess

Posted: Tue Jun 26, 2007 2:43 am
by Gente
Hockey wrote:

Code: Select all

....
RewriteRule ^(.+).php$ index.php?page=$1 [QSA]

Code: Select all

RewriteRule ^(.+)\.php$ index.php?page=$1 [QSA]

Posted: Wed Jun 27, 2007 12:16 am
by alex.barylski
Update: It's just one directory within the hierarchy that needs public access, so cannot I not use a simple alias after that last rewrite rule???

Code: Select all

/index.php
 /assets/
 /core/
 /temp/
Core and Temp do not and should not be accessible directly from URL requests. Everything inside assets however I want accessed normally, because they are images, JS, etc which compose the index.php output...

--- Done Edit ---

Everything is fine, but now I need the .htaccess to ignore a directory named 'assets'

Code: Select all

RewriteEngine on
RewriteBase /

RewriteRule ^(.+)$ index.php?path=$1 [QSA]
I have tried adding the rule:

Code: Select all

RewriteRule !(assets)
But That choked the system...I'm not sure where or how I add exceptions to the above "redirect everything to index.php" rule :)

Posted: Wed Jun 27, 2007 4:48 am
by Gente

Code: Select all

RewriteEngine on
RewriteBase /

RewriteRule ^assets/ - [L]
RewriteRule ^(.+)$ index.php?path=$1 [QSA]
Try it

Posted: Wed Jun 27, 2007 12:33 pm
by alex.barylski
Perfect, thanks :)

I had something alsmot like that, missing the '-' though which seems to be the critical factor.