please help with mod_rewrite rules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx




[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux