Solved

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

Posted on 2008-09-30
3
273 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 500 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PHP clean up nicely even if user abort 13 49
slow web access in oversea location 3 35
How to analyze web traffic logs 10 90
file path 14 63
Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

759 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

20 Experts available now in Live!

Get 1:1 Help Now