Solved

mod_rewrite question

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

809 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