PHP Coding Tips

Wednesday, August 8, 2012

Deal with path errors when using mod rewrite and directory-like url

If you are using directory-like url's like this:mysite.com/one/two/threeany css or javascript file accesed by "script.js" will be searched in /one/two/three/scrit.js when 404 error will occur. Add a slash symbol at begining of path to access that file from global context like "/script.js". This is also useful for broken mod-rewrite links, like 404 error on /one/two/index.php. Your href attribute should be set to "/index.php" not "index.php" or whole address: "http://mysite.com/index.php". You can write your own href-generating function/class that will append your current domain to every link.

No comments:

Post a Comment