Jump to content

mod_rewrite, style missing when in sub-folder


Zerpex

Recommended Posts

Hello everyone,

 

I can't connect to IRC at the moment :/ Anyways, I'm creating a site, where I use 'pretty' urls, I'm rewriting etc contact.php to contact/

 

At the moment I'm on localhost/website/ and everything is working great! but as soon as I go to localhost/website/contact/ all the styles, and images, and JS is missing :/

 

This is how my RewriteEngine is at the moment:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)/$ $1.php [L,QSA]

Your various img and script srcs, link and whatever else hrefs all need to be absolute. Right now they have relative URLs like


Or maybe ../path. Whatever. Those are all relative paths and they're relative to the current page. Go into enough subdirectories and the paths will break.

 

Change them to include a leading slash:


That way they'll always come out of the same place regardless of the current page.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.