Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 05-15-2008, 10:53 PM   #1
Registered: Dec 2007
Location: ON CA
Distribution: Xubuntu 8.04; Xubuntu 6.06.2
Posts: 64

Rep: Reputation: 15
[SOLVED] Apache: Need helping rewriting URLs


I need help rewriting URLs in Apache (1.3.37). I want the 'www.' to be stripped while preserving the directory structure. For example: If a user types '' the URL should be rewritten as '' and the root of my OpenOffice mirror should be shown.

I'm having a really hard time coming up with the correct rewrite conditions. So far I was able to come up with the following:
RewriteCond %{HTTP_HOST} ^$
RewriteRule ^(.*)$ [R=301,L]
but this doesn't take into account the directory structure, and regardless of the path specified, if the address is prefixed with 'www.' the home page will always be displayed.

Please note that I am not the admin of the system and don't have access to Apache's configuration files. I can only use .htaccess.

Thank you.

Last edited by hex1a4; 05-20-2008 at 07:13 PM. Reason: SOLVED
Old 05-20-2008, 09:31 AM   #2
Registered: Dec 2007
Location: ON CA
Distribution: Xubuntu 8.04; Xubuntu 6.06.2
Posts: 64

Original Poster
Rep: Reputation: 15
Well I've been reading up on rewriting URLs creating some easier ones, and it turns out this is just as easy. Here's how I did it:
RewriteCond %{HTTP_HOST} ^www\.hex1a4\.net(.*)$
RewriteRule ^(.*)$$1 [R=301,L]


apache, http, rewrite, url

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache URLS riluve Linux - Software 7 08-30-2007 06:51 AM
Helping in implementing a public_html in apache adam_blackice Linux - Server 4 08-08-2007 03:46 AM
Apache: prevent logging certain URLs ? michaelsanford Linux - Software 1 07-22-2005 07:48 PM
mod_rewrite not rewriting urls chr15t0 Linux - General 1 11-09-2003 04:45 AM
apache and urls ferretmanus Linux - Newbie 1 09-16-2003 01:25 PM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:02 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration