Mod rewrite with subdir problems

software development

#1

Hi,

I am trying to use mod rewrite right now with subdirectories but they are not loading the CSS/images files correctly.

here’s some sample code I have in my .htaccess file in my root:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^mysite/([A-Za-z]+)/([0-9]+).html /mysite/index.php?name=$1&id=$2 [L]

The problem is it loads all the content correctly excepted any CSS files or images that are using this type of img src url: “./location_of_image.jpg”. Any hardcoded image works fine.

If I change the [L] to [R], it also works fine.

If I use this mod-rewrite rule it also works fine e.g. loads everything including css and img files correctly:

RewriteRule ^mysite/([A-Za-z]+)-([0-9]+).html /mysite/index.php?name=$1&id=$2 [L]

I don’t understand what’s going on. I thought you can use pseudo virtual directories, but it seems like you cant.

Does anyone know why this is happening or what I am doing wrong? Thanks


#2

nevermind i figured it out… i had to add a “http://domain.com” in front of “/mysite…”