NYCPHP Meetup

NYPHP.org

[nycphp-talk] Mod_rewrite and pretty urls problem

Cliff Hirsch cliff at pinestream.com
Tue Feb 5 10:27:10 EST 2008


For pretty urls, I have set up mod_rewrite like so:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1

For a page like www.domain.com/faq the controller captures the faq command
and everything works fine.

But for www.domain.com/faq/ the images, css and javascript files are all
missing. They are all set up as relative links. I¹m assuming that there are
now relative to the /faq directory, which does not exist. Is this a
side-effect of mod_rewrite? If so, how do you prevent it? Make all images,
css and JS files absolute links or always relative to root?

Also, what is the proper RewriteRule to preserve get query variables?

Something like RewriteRule ?(.*)$ index.php?$1

Cliff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20080205/e58edfab/attachment.html>


More information about the talk mailing list