简体   繁体   中英

Mod_rewrite - CSS, JS and Images not working

it's my first time I am asking a Question here.
I have a problem with mod_rewrite.

I have the following filesystem structure:

site_new/stylesheets/layout.css  
site_new/javascript/somescript.js  
site_new/hallendetails.php  
site_new/etc...

Now I tried to redirect my php Page to an html file via mod_rewrite.
It works fine, my .htaccess looks like that:

RewriteEngine on  
RewriteBase /site_new/  
RewriteRule ^(.*)/(.*).html$ hallendetails.php?id=$1&halle=$2 [L]  

The orignial url is:

localhost/site_new/hallendetails.php?id=01&halle=Heimspielhalle_Gaissacher_Strasse

The "new" url then is:

localhost/site_new/01/Heimspielhalle_Gaissacher_Strasse.html

Now all my CSS, JS and Image files are broken.
They are included like that:
type="text/css" href="stylesheets/layout.css"

But after redirecting they are searched in

/site_new/01/stylesheets/layout.css

I think I need a RewriteCond, but I don't know how to write it. I tried lots of ways, but I don't get it.

Please help!

使用mod_rewrite时尝试css,images,js的绝对路径

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM