Solved

mod_rewrite question

Posted on 2011-09-15
4
318 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

740 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