Desperate: Rewrite directory to another directory

New to mod_rewrite? This is a good place to start.

Desperate: Rewrite directory to another directory

Postby Xerxes » Sun May 07, 2006 12:55 am

I've been trying for the last 4 hours, dozens and dozens of variants to get this working and I'm not any closer to getting it right.

Say my site is www.bleh.com. I have a real directory called apples. I want to give links out that goto a directory called oranges that does not really exist. The oranges directory will just pull up files from the apples directory. However, the url needs to stay as oranges and the customer should not notice anything than if they went to the apples directory.

This seems really easy.

Real directories/files:
www.bleh.com/apples/bleh.php
www.bleh.com/apples/desert/yum.php

Links given out (the directory does not really exist)
www.bleh.com/oranges/bleh.php
www.bleh.com/oranges/desert/yum.php

Help, please!
Xerxes
 
Posts: 2
Joined: Sun May 07, 2006 12:48 am

Postby richardk » Sun May 07, 2006 3:36 am

Put this in a .htaccess file in your / (root) directory.
Code: Select all
RewriteEngine On

RewriteRule ^oranges/(.*)$ /apples/$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Xerxes » Sun May 07, 2006 7:33 am

Thanks it worked! Appreciate it!
Xerxes
 
Posts: 2
Joined: Sun May 07, 2006 12:48 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 24 guests

cron