Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

mod_rewrite question

Posted on 2011-09-15
4
Medium Priority
?
331 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 2000 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

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…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month11 days, 19 hours left to enroll

916 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