LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices



Reply
 
Search this Thread
Old 05-15-2008, 11:53 PM   #1
hex1a4
Member
 
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


Hi,

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 'www.hex1a4.net/mirror/openoffice/' the URL should be rewritten as 'hex1a4.net/mirror/openoffice/' 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:
Code:
RewriteCond %{HTTP_HOST} ^www.hex1a4.net$
RewriteRule ^(.*)$ http://hex1a4.net/ [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 08:13 PM. Reason: SOLVED
 
Old 05-20-2008, 10:31 AM   #2
hex1a4
Member
 
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:
Code:
RewriteCond %{HTTP_HOST} ^www\.hex1a4\.net(.*)$
RewriteRule ^(.*)$ http://hex1a4.net/$1 [R=301,L]
 
  


Reply

Tags
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 07:51 AM
Helping in implementing a public_html in apache adam_blackice Linux - Server 4 08-08-2007 04:46 AM
Apache: prevent logging certain URLs ? michaelsanford Linux - Software 1 07-22-2005 08:48 PM
mod_rewrite not rewriting urls chr15t0 Linux - General 1 11-09-2003 05:45 AM
apache and urls ferretmanus Linux - Newbie 1 09-16-2003 02:25 PM


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

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