Solved

mod_rewrite question

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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching 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.

747 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now