Hi, I see there are at least a few posts about this topic already, but I can't really find a solution... I've got a few RewriteRules in an .htaccess file, for example: RewriteRule ^portfolio/([0-9]+)$ project.php?gallery=$1 RewriteRule ^portfolio$ gallery.php [NC] Code (markup): This works perfectly to redirect traffic and clean up the urls, but it breaks all the relative paths in the html; img/file.ext becomes portfolio/img/file.ext. The obvious answer to this is to make the paths absolute (/img/file.ext), but that makes development a mission as the site always has to be in the rood directory. If it's living on a testing server (www.mydomain.com/projects/client/version/img/file.ext) it all breaks, as you'd expect. So... what's the answer? Is there a way of telling apache that the root folder is "http://www.mydomain.com/projects/clients/version/"?? That way you can make all the paths absolute, fixing the url problem. And if I move the site to a new location I only have to change the one directive, fixing the portability problem? Thanks
The cure is to declare as the first line of your <head> the site base. I am using php so I have that defined in my configure file. In the head I use: In the config file $sitebase is defined as: I can't find the original post but you should be able to work it backwards from there.
base? I've never seen that! That's perfect! I've done (as a stopgap, hoping I'd figure it out) almost the same thing; defining a root php constant in my config file, but I've been putting a little pho echo in front of every URL! Not the most convenient way to do it. This makes it much easier. Thanks
It drove me crazy for years. I used 2 different menus and lots of other work arounds. Coulld not figure out what to search for in terms of the answer. A poster in another forum gave me the solution just a week ago. Happy to spread the cheer.