Solved

.htaccess ro run multiple sites

Posted on 2007-04-02
1
192 Views
Last Modified: 2010-03-04
This file works great, but only for 1 domain. I need to add a 2nd running from the folder /v2/

Its fine to show the subfolder in the urls, but I would also like this script to check for the "www." prefix and remove it. How can I configure the htaccess to rewrite the urls properly ?

Goal ..
http :// domain1 .com /site/
http :// domain2 .com /v2/

Here is the code Im starting with:
---
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^$ /site/ [L,R]
0
Comment
Question by:mcsolas
1 Comment
 
LVL 11

Accepted Solution

by:
JamesCssl earned 500 total points
Comment Utility
#remove the WWW
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^/?(.*) http://%1/$1 [R=301,L]

# example.com
RewriteCond %{REQUEST_URI} !^/?site
RewriteCond %{HTTP_HOST} example\.com [NC]
RewriteRule ^/?(.*)$ /site/$1 [L]
RewriteRule ^/?site/$ - [L]

# example.net
RewriteCond %{REQUEST_URI} !^/?v2
RewriteCond %{HTTP_HOST} example\.net [NC]
RewriteRule ^/?(.*)$ /v2/$1 [L]
RewriteRule ^/?v2/$ - [L]

Replace example.com and example.net with your domains, and "site" and "v2" with your paths.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

11 Experts available now in Live!

Get 1:1 Help Now