Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

.htaccess ro run multiple sites

Posted on 2007-04-02
1
Medium Priority
?
202 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
[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
1 Comment
 
LVL 11

Accepted Solution

by:
JamesCssl earned 2000 total points
ID: 18841045
#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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

715 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