Solved

mod_rewrite question

Posted on 2011-09-15
4
325 Views
Last Modified: 2012-08-13
Hi,

With my curent hosting company, the parent domain (mydomain.com) in the public_html directory with all of the other domain folders. The parent domain does not have it's own folder.

How can I use an .htaccess file to redirect everything from mydomain.com to the folder I will create for this domain?

Also, is google cool with this? I'm not using mydomain.com for public use, will it affect my other domains with google?
0
Comment
Question by:Computer Guy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Expert Comment

by:jeremycrussell
ID: 36545897
It would be best to simply change the "DocumentRoot" for the VirtualHost (sounds like you are doing some type of virtualhosting) if you can.

However... to use a rewrite, something like:

RewriteEngine On
RewriteRule ^/(.*)$ /directoryyoucreate/$1

Open in new window


Sounds like it would do what I understand you to be asking.
0
 
LVL 3

Author Comment

by:Computer Guy
ID: 36545947
I take it the ".*" seperates actual files from folders?
0
 
LVL 9

Accepted Solution

by:
jeremycrussell earned 500 total points
ID: 36545991
No, it's just a regular expression to "catch" everything.

If I understand correctly...  the DocumentRoot for mydomain.com is /something/public_html...

so, for instance mydomain.com/index.html maps to /something/public_html/index.html.

But, you want mydomain.com to effectively use /something/public_html/somedirectory/ as it's root...

So if someone goes to mydomain.com/index.html it actually has them go to /something/public_html/somedirectory/index.html

This rule would rewrite any uri on mydomain.com to be prepended with /somedirectory/ effectively making it the root.

So, for instance...  http://www.mydomain.com/images/thisimage.png would be redirected to http://www.mydomain.com/somedirectory/images/thisimage.png. etc.... etc....
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36545996
I 100% agree with Jeremy, setting up DocumentRoot's for each vhost (including parent) is definitely the cleanest and easiest-to-scale way to do this.
0

Featured Post

Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question