apache htaccess mod rewrite images + stylesheets fix

Hi

I have been working with httacess mod rewrite for a while now and know the basics (although my reg ex is still very very limited)

I have always come across the same issue with images and style sheets where by i have to use root relative paths to images + stylesheets etc.

1.
Are there any techniques out there to rewite stylesheets and images aswell or do i have to keep using root relative paths?

2.
Be great to hear people opinions on using root relative paths vs document relative paths and their use where site uses mod rewrite.

Looking forward to hearing your thoughts.

Many thanks

--s--
LVL 1
socrossAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

caterham_wwwCommented:
> Are there any techniques out there to rewite stylesheets and images aswell

You can rewrite wrong paths, yes, the easiest way would be if images/stylesheets are in a separate folder

         RewriteRule /(images/.*) /$1 [R=301,L]
will redirect /foo/images/abc... or /foo/bar/images/abc... to /images/abc... (if the requst was /images/... the rule will match in .htaccess files against images/.. only, w/o the leading slash)

> Be great to hear people opinions on using root relative paths vs document relative paths

If you're using a virtual folder structure,  I think you're using absolute links to your html site files - otherwise links may point to wrong locations, too, which is not a good idea (search engines). Another approach instead of an absolute path like /images/foo.jpg (leading slash) is <base href="http://example.com/"> in your <head> section, which should solve the problem, too.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.