开发者

mod_rewrite for friendly urls unexpected behaviour

I have Apache and I have this in the .htaccess file:

RewriteEngine on
RewriteRule ^myhome myhome.php

because I want to redirect /myhome/ to /myhome.php. It works, but it behaves unusually.

When I type in myurl.com/myhome, it redirects to myurl.com/myhome.php correctly, but when I try myurl.com/myhome/ with the slash at the end, it redirects to the page but it can't find any stylesheets or images (the paths for which are relative).

The code references "image.png" and "style.css" and without the slash at the end, it works and loads those files开发者_如何学Python correctly, but with the slash, it doesn't. I think this is because it's thinking it's loading from the myhome/ directory now instead of the base directory. Could anyone tell me how to get it working right?


appending / at last makes as if u are browsing default page of myhome directory i.e myhome/index.htm

generally i use html tag base url and add my site url there for my working on my site.

<base href="http://www.myurl.com" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜