I wonder if anyone can help with the below and if it is even possible.
I have a server running apache and know a little about url re-writing and wondered if it is possible to use url rewriting for paths for images and css.
so my current file structure is this:
/index.php
/theme/css/default.css
/theme/images/image1.jpg
in index.php i have the css linked to
/theme/css/default.css
but what i would actually like to display is
/css/default.css
also images a开发者_如何学运维re the same where i include an image it is
<img src=/theme/imaages/image1.jpg>
is it possible through rewriting to have
<img src=/imaages/image1.jpg>
Thanks.
Copy this code to your .htaccess
RewriteEngine On
RewriteBase /
RewriteRule ^theme/([a-z]+)/([a-z\-_\.]+)$ /$1/$2 [QSA,L]
(Make sure mod_rewrite is enable)
All the <img src="/images/image1.jpg">
will redirect to <img src="/theme/images/image1.jpg">
as well all the CSS files.
精彩评论