How can I rewrite the image paths on my web server?
May 21, 2009 5:09 PM
How can I rewrite the image paths on my web server?
I recently moved a site into a CMS and different web server. The images are in directories like this:
/daily/2009/05/
The web pages sometimes link to images like this:
[img src="/daily/2009/05/"]
And sometimes they link to images like this (without a leading slash):
[img src="daily/2009/05/"]
That worked fine on the old server, but the paths are different in the CMS on the new server. Can I use .htaccess or something to rewrite the paths?
I recently moved a site into a CMS and different web server. The images are in directories like this:
/daily/2009/05/
The web pages sometimes link to images like this:
[img src="/daily/2009/05/"]
And sometimes they link to images like this (without a leading slash):
[img src="daily/2009/05/"]
That worked fine on the old server, but the paths are different in the CMS on the new server. Can I use .htaccess or something to rewrite the paths?
"Rewrite" usually has a fairly specific meaning referring to an internal operation within a running web server that causes each HTTP request to return a file at a different location than the request's URL would normally correspond to. Is that what you're talking about doing?
And more generally, whatever you mean in particular by "rewrite", are you asking about this to remedy a problem involving broken image links or for a different reason?
posted by XMLicious at 7:31 PM on May 21, 2009
And more generally, whatever you mean in particular by "rewrite", are you asking about this to remedy a problem involving broken image links or for a different reason?
posted by XMLicious at 7:31 PM on May 21, 2009
ExpressionEngine, MySQL, broken image links.
posted by kirkaracha at 7:33 PM on May 21, 2009
posted by kirkaracha at 7:33 PM on May 21, 2009
Assuming /daily/ is the correct link, and doesn't appear in other URLs then you could probably do something like (not tested):
RewriteRule ^.+/daily/(.+)$ /daily/$1
Should match anything where there are path parts before the /daily/ (so where the image URL has been linked as a relative link) and rewrite to an absolute root-based URL.
posted by sycophant at 1:47 AM on May 22, 2009
RewriteRule ^.+/daily/(.+)$ /daily/$1
Should match anything where there are path parts before the /daily/ (so where the image URL has been linked as a relative link) and rewrite to an absolute root-based URL.
posted by sycophant at 1:47 AM on May 22, 2009
This thread is closed to new comments.
posted by bricoleur at 6:48 PM on May 21, 2009