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]

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.