httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Igor Cicimov <icici...@gmail.com>
Subject Re: [users@httpd] please help with mod_rewrite rules
Date Sun, 30 May 2010 01:04:28 GMT
Use the proxy flag P in the redirect to preserve the url but have in mind
that it will work for the first page only. When you click on any link on it
the url will be changed to the new one then.

Sent from my phone

On May 30, 2010 5:20 AM, "Mari Masuda" <mari.masuda@stanford.edu> wrote:

Hello,

I am moving a large website from a proprietary CMS to Drupal.  In the
proprietary CMS, all media files (images, pdfs, etc.) have URLs like
http://media.xxx.org/images/blah.jpg or
http://media.xxx.org/documents/blah.pdf.  In my Drupal .htaccess I have
created the following two mod_rewrite rules so that the old URLs will
continue to work and so we can continue using the scheme of
http://media.xxx.org/images/whatever.jpg instead of using the Drupal
location:

---
 # handle imagecache images
 RewriteCond %{HTTP_HOST} ^media\.(xxx|xxx-stage)\.org$
 RewriteCond %{QUERY_STRING}
^size=(x_small|small|medium_small|medium_large|large)$
 RewriteRule ^/?(.*) /imagecache/%1/$1? [L,NE]

 # handle requests for things at media.xxx.org
 RewriteCond %{HTTP_HOST} ^media\.(xxx|xxx-stage)\.org$
 RewriteRule ^/?(.*) http://media.%1.org/sites/default/files/$1 [L]
---

I am not that experienced in regular expressions or mod_rewrite so I am
actually not completely sure how I got the above rewrite rules to work, but
they do actually work.  (Beginner's luck, I guess!)  In the actual
RewriteRule of the second block (i.e., RewriteRule ^/?(.*) http://media.%
1.org/sites/default/files/$1 [L]) I had to put the http://media.%1.org/ in
order to get it to work.  My question is how can I mask the rewritten URL so
in the browser's address bar it just shows
http://media.xxx.org/images/blah.jpg instead of
http://media.xxx.org/sites/default/files/images/blah.jpg?  To complicate
matters, I believe our host uses a link of some sort so that
http://media.xxx.org/sites/default/files is actually a link to
/some/other/path/on/the/server.  When I was looking at the Apache
documentation it seemed like Alias or AliasMatch would be the thing to use
to mask the URL but I could not figure out how to get it to work.

Thank you for any tips!

Mari
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
  "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Mime
View raw message