Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Im not familiar with apache2's rewrite engine so i need someone's help to create a rewrite rule. Im trying to redirect this folder's and its content's url: http://mysite.com/junk/

to http://files.anotherone.com/misc/

share|improve this question
1  
Just to be clear, you don't redirect a folder to a URL, you redirect the URL to a folder. It's important to understand the difference. –  John Gardeniers Sep 5 '12 at 8:11

2 Answers 2

up vote 2 down vote accepted

I'll forgive your apparent lack of documentation-reading because the documentation for mod_rewrite is pretty unreadable. Thing is, you don't need mod_rewrite. (This is my favorite link for Server Fault.)

Much lighter and easier to understand if you just use mod_redirect:

Redirect /junk/ http://files.anotherone.com/misc/

Also, you'll want to read the fine documentation on .htaccess files, particularly the part that says

You should avoid using .htaccess files completely if you have access to httpd main server config file. Using .htaccess files slows down your Apache http server. Any directive that you can include in a .htaccess file is better set in a Directory block, as it will have the same effect with better performance.

share|improve this answer
    
Hi, this is actually way better. Thanks –  Adonis K. Oct 2 '12 at 18:00

You can use a simple .htaccess rewrite like:

RewriteEngine on
RewriteRule ^(.*)$ http://files.anotherone.com/misc/$1 [R=301]

This should be placed under the .htaccess file located in the /junk directory of mysite.com

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.