Redirecting one folder behind the screens

Ask your mod_rewrite and Redirection questions here, and get answers!

Redirecting one folder behind the screens

Postby fuego » 07 May 2008 03:12

Hello,

I would like to do the following:

Let's say the folder structure on my server looks like this:

Code: Select all
http: //example.com/examples/website1
http: //example.com/examples/website1/folderA

http: //example.com/examples/website2/
http: //example.com/examples/website2/folderA

http: //example.com/examples/template/
http: //example.com/examples/template/folderA
http: //example.com/examples/template/folderB

I would like to have a .htaccess file which makes some kind of a redirect, so that users can type in: http://example.com/examples/website1/folderB while they are actually looking to the website in the /template/ folder. The browser URL should be displaying the address with /website1/.

The reason for this is that we are creating websites for customers which are partly the same. We don't want to upload the same data over and over again.

Does anyone know if this is possible? Thanks in advance!
fuego
 
Posts: 3
Joined: 07 May 2008 03:03

Re: Redirecting one folder behind the screens

Postby mod_rewrite » 09 May 2008 22:21

This is easily accomplished, but could you provide more examples of urls that will be typed in the browser and the actual file/folder to be displayed?
mod_rewrite
 
Posts: 102
Joined: 30 Oct 2006 19:55

Re: Redirecting one folder behind the screens

Postby fuego » 15 May 2008 06:18

Thank you for your reply!

All of these:

http: //www.example.com.au/websites/website1/Gen
http: //www.example.com.au/websites/website2/Gen
http: //www.example.com.au/websites/website3/Gen

Should all point to:

http: //www.example.com.au/websites/website_template/Gen

But the display URL should still be (for example) http: //www.example.com.au/websites/website1/Gen

We currently upload the same Gen folder into each website folder now, but this takes up a lot of storage on our webhost.
fuego
 
Posts: 3
Joined: 07 May 2008 03:03

Re: Redirecting one folder behind the screens

Postby htaccess » 15 May 2008 09:05

You could place this in the folder /websites/.htaccess
Code: Select all
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]+)/Gen(.*)$ /website_template/Gen$1 [NC,L]
htaccess
 
Posts: 48
Joined: 28 Feb 2007 17:16

Re: Redirecting one folder behind the screens

Postby fuego » 17 May 2008 07:17

Thank you very much! I'm going to try it soon.
fuego
 
Posts: 3
Joined: 07 May 2008 03:03


Return to Redirect or Rewrite Questions



Who is online

Users browsing this forum: clerkfurniture, HIBcokyacrornsap, ShakhtarrDon, VocrepeAcceby, Zitioutbava