BleepingComputer.com: .htaccess Redirection

Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

.htaccess Redirection Preserve file path, change subdomain

#1 User is offline   Andrew 

  • Bleepin' Night Watchman
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 7,329
  • Joined: 05-December 05
  • Gender:Not Telling
  • Location:Right behind you

Posted 27 February 2010 - 05:35 PM

So I want to redirect certain requests which formerly went to www.example.com/Files/ to files.example.com/ while preserving the relative address of the request. what I mean is that a request to www.example.com/Files/xyz.zip would get redirected to files.example.com/bin/xyz.zip. I know how to do this by creating a redirect for each file, but I was hoping to be able to create a single rule that handles all files at once.

Any ideas?
Help us help you. If HelpBot replies, you MUST follow step 1 in its reply so we know you need help.
Posted Image
Boredom Software Stop Highlighting Things

#2 User is offline   BabyGuard 

  • New Member
  • Pip
  • Find Topics
  • Group: Members
  • Posts: 4
  • Joined: 05-March 10
  • Location:Sunrise, FL

Posted 05 March 2010 - 10:04 AM

Try adding the following code into your .htaccess file

RewriteEngine On
RewriteCond %{HTTP_HOST} !^(.*)\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]


That is just a redirect code to make all non-www request point to the www.example.com domain. You may or may not be able to edit this to work the way you want it but that's something for you to try out. Good luck!

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users