Forum Moderators: phranque
That is the problem, since it is the client (browser or search engine robot) that resolves relative URLs based on the URL it is currently looking at. Therefore, the 'base' URL for your example article is now "www.example.com/articles/news/", to which the relative image links are 'added'.
This will affect images, external CSS and JavaScript files, multimedia files --anything included as an object on your HTML pages-- as well as relative links to other pages outside that 'base' path.
The correct solution is to use server-relative or canonical URLs for image links. That is, start your image and other included-object links with a slash or with [<domain>...]
The other solution is to add a second rule (an internal rewrite) that removes or replaces the "/articles/news/" path from all included-object URLs. The problem with this is that it creates duplicate-content issues for all of those URLs. Also any objects shared between the "articles/news" URL-space and others on your site will be treated as separate objects from a caching viewpoint, potentially making your site far less efficient -- Remember that caching is based on an object's URL, not its "file location."
Jim
<img src="/image.jpg" /> Instead of:
<img src="image.jpg" /> ?
Sorry to be honest that last paragraph is completely lost on me! I only just started using mod_rewrite from a tutorial last night and got the main part to work (/articles/news/###).
Thanks for your help!
/images/ folder on your server, rather than dumping many files into the site root. I try to hold the minimum amount of files in the root: the .htaccess file, the index page, the robots.txt file, any SE account verification files, and so on.
Images, stylesheets, scripts, and so on, have their own separate folders.