开发者

No images on a web page when using rewriterule

I have a .htaccess file like this:

RewriteRule ^(iphone)/(.*)\.html$ /$2.php?specialversion=$1 [L,QSA]

My problem is that when viewing http://www.example.com/iphone/mypage2.html, mypage2.php 开发者_JS百科gets called and output contents but none of the images or even the CSS are working. How can I solve this?


You could use a new HEAD tag in your HTML in mypage2.php (and the other pages), when GET specialversion is set. The images will otherwise be fetched from http://www.example.com/iphone/images/... or similar, which is not redirected):

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

Of course, you could use another RewriteRule in the .htaccess instead.

RewriteRule ^(iphone/(?:images|style))/(.*)$ /$2.php?specialversion=$1 [L,QSA]

This RewriteRule rewrites images and style dirs. Remember that the cache wouldn't be used if a client uses both the main site and the iphone site (which probably isn't a problem).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜