Results 1 to 2 of 2

Help with .htaccess redirect of directory to another domain

This is a discussion on Help with .htaccess redirect of directory to another domain within the General Discussion forums, part of the vBSEO SEO Plugin category; I was hoping one of the .htaccess mod_rewrite gurus can provide me with some code/guidance. I am starting to leverage ...

  1. #1
    Senior Member Array
    Real Name
    Juan
    Join Date
    Aug 2007
    Posts
    132
    Liked
    0 times

    Help with .htaccess redirect of directory to another domain

    I was hoping one of the .htaccess mod_rewrite gurus can provide me with some code/guidance. I am starting to leverage a Content Delivery Network (CDN), and would like any requests made to my www.domain.com/images folder to be remapped to cdn.domain.com/images. Is there a quick/easy way that I can add this rule?

    I'd ideally want to do this to several of my images directories. What is the best way to do this? From the root/.htaccess? Or from an .htaccess file placed within the affected directory itself?

  2. #2
    Senior Member Array
    Real Name
    Ceri May
    Join Date
    Jul 2009
    Location
    United Kingdom
    Posts
    1,726
    Liked
    15 times
    Blog Entries
    1
    I would place a .htaccess in each effected directory personally but then it will depend on how many your talking about, if there is say more than 4 folders then its better to delete the folders and use the root .htaccess

    If you are placing one in each folder simply this will work.

    RewriteEngine On
    RewriteRule (.*) http://cdn.domain.com/images/$1 [L,R=301]
    If you are doing it from root it is almost identical but it would be

    I would place a .htaccess in each effected directory personally but then it will depend on how many your talking about, if there is say more than 4 folders then its better to delete the folders and use the root .htaccess

    If you are placing one in each folder simply this will work.

    RewriteEngine On
    RewriteRule ^images/(.*) http://cdn.domain.com/images/$1 [L,R=301]
    RewriteRule ^img/(.*) http://cdn.domain.com/img/$1[L,R=301]
    RewriteRule ^graph/(.*) http://cdn.domain.com/charts/$1[L,R=301]
    As an example, if you are adding it to the vBSEO standard .htaccess though you can omit the RewriteEngine On and just make sure the rules go above the vBSEO rules.

    Ceri

Similar Threads

  1. Replies: 2
    Last Post: 12-24-2009, 04:52 AM
  2. Replies: 4
    Last Post: 11-04-2009, 06:07 PM
  3. Sub-Domain or directory?
    By billyjohnsonjr in forum General Discussion
    Replies: 2
    Last Post: 06-01-2008, 02:46 PM
  4. Redirect parked domain to primary domain
    By Arkidas in forum General Discussion
    Replies: 9
    Last Post: 03-20-2008, 06:19 PM
  5. redirect domain.com/index.php to www.domain.com/
    By LarryEitel in forum Custom Rewrite Rules
    Replies: 4
    Last Post: 07-05-2006, 10:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •