473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Redirecting subfolder to other URL

Is there any way using either Apache or some other method that I can redirect requests to a specific subfolder to another URL?

For example, when somebody types in http://www.mydomain.com/email they get redirected automagically to http://www.mydomain.com/?p=email, or something like that.

I'm sure this is a simple question but I am fairly new to web hosting so I'm not sure how to accomplish this. Thanks in advance to whomever helps.
Nov 20 '07 #1
2 5110
Edan
5
Definitely.
You can use mod_rewrite.

First, you must enable mod_rewrite in httpd.conf. Find the following line and uncomment it (If you have no access to this file, just ask your host company to enable mod_rewrite).

Expand|Select|Wrap|Line Numbers
  1. #LoadModule rewrite_module modules/mod_rewrite.so
Now create a file named ".htaccess" in your main www directory (or modify an existing one), and write the following:

Expand|Select|Wrap|Line Numbers
  1. RewriteEngine on
  2. RewriteRule ^email/?$ /?p=email [L]
You can add more rewrite rules like this:

Expand|Select|Wrap|Line Numbers
  1. RewriteEngine on
  2. RewriteRule ^email/?$ /?p=email [L]
  3. RewriteRule ^home/?$ /?p=home [L]
  4. RewriteRule ^something/?$ /page.php?q=whatever [L]
I believe it should work.
Anyway, that's very specific and mod_rewrite is capable of more.
If you want to learn more about mod rewrite --
http://www.google.com/search?hl=en&q=mod+rewrite+guide&btnG=Google+Searc h


Edan
Dec 8 '07 #2
Markus
6,050 Expert 4TB
Or you could just do this through htaccess

Expand|Select|Wrap|Line Numbers
  1. redirect email/ /?p=email
  2.  
The difference between mine and edans method is that mine will actually redirect the user from that folder to the directory you specify; with edan's the user will believe (s)he is still at the yoursite.com/email directory as with the rule he wrote the [L] forces the url tp remain the same but the properties to change.

That's how places like myspace have their user pages

i.e. www.myspace.com/userprofile
is changed (through htaccess) to something like:
www.myspace.com/?userID=userprofile

Ofcourse, edan's rule wont do that for you, you'd have to expand it slightly, but that's the gist.

Sorry about the rant - haha.

-markus
Dec 9 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Kris van der Mast | last post by:
Hi, I've created a little site for my sports club. In the root folder there are pages that are viewable by every anonymous user but at a certain subfolder my administration pages should be...
2
by: | last post by:
Let me explain step wise. 1.. I have a site running on port 5555 2.. If contains web.config file with contains <Forms> authentication. 3.. The site contains a sub-folder named "MembersArea"...
0
by: Johnnie Norsworthy | last post by:
I have a web site Domain1.com and a secondary domain, Domain2.com that is forwarded by my registrar to Domain1.com. Using my primary home page: http://domain1.com/default.aspx is there a way I...
4
by: Greg Smalter | last post by:
Redirecting from page to page within a web project is pretty easy. However, all Redirect methods take strings as arguments, as if you mistype the string, you don't find out until run time that you...
3
by: walter | last post by:
Hi , I thought it's simple ,but end up come here for help(as lots of other times). --I have several HttpModule added in the root thru web.config, but I want to remove some and add some new ones in...
7
by: MarkusJNZ | last post by:
Hi, I have a website called www.websitename.com which is an ASP.NET 2.0 website. I need to create another application (Which I want to be totally seperate from the above website) but for...
9
by: Jonathan Wood | last post by:
I've spent days trying to come up with a solution. I'd appreciate it if anyone can help. My site requires all users to log on. There are three different roles of users, and each user type will...
5
by: woolls01 | last post by:
I am using the following code Sub Ck() Dim strStartPath As String strStartPath = "d:\workpack\rra" ListFolder strStartPath End Sub
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.