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

x
?
Solved

.htaccess - Need to send non-full-url to full url. (intranet -> intranet.hostname.com)

Posted on 2008-09-30
3
Medium Priority
?
283 Views
Last Modified: 2012-05-05
Hi all.
Using Apache and Joomla for our corp. intranet.

The intranet is accessed by a variety af url's
http://intranet http://intranet2 http://trgnet http://intranet.ourhostname.com

I want to use .htaccess to redirect all access to the full url - http://intranet.company.com

A working example would be great :-)

Thx,
Mark
0
Comment
Question by:trg_dk
3 Comments
 
LVL 20

Expert Comment

by:edster9999
ID: 22605615
You could do something like :
Redirect / http://intranet.company.com

You have to be careful if the new webserver is on the same box in case you get caught in a loop.

This also means the web server must be up to resolve these names and server the redirection.

A better way would be to NOT do this in .htaccess but do it all in the DNS server then when they request a page they will end up on the right server without hitting the other web server.
Something like :

intranet        IN      CNAME   intranet.company.com.
intranet2      IN      CNAME   intranet.company.com.
trgnet          IN      CNAME   intranet.company.com.
intranet.ourhostname.com       IN      CNAME   intranet.company.com.



0
 
LVL 27

Accepted Solution

by:
caterham_www earned 2000 total points
ID: 22605648
You can check the http host with mod_rewrite only (an other approach would be to use a separate virtual host for all non-full urls and place  Redirect statement there.)

Make sure apache's module  mod_rewrite is loaded and your webserver is configured that you're allowed to use such directives in a .htaccess file.
RewriteEngine on
RewriteCond %{HTTP_HOST} !=intranet.company.com
RewriteCond %{HTTP_HOST} !=""
RewriteRule ^ http://intranet.company.com%{REQUEST_URI} [R=301,L]

Open in new window

0
 
LVL 2

Author Closing Comment

by:trg_dk
ID: 31501479
Thanks for your reply - works like a charm
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month11 days, 10 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