Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    [SOLVED] Apache: Need help rewriting URLs


    I need help rewriting URLs in Apache. 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 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.The Apache version is 1.3.37
    Linux user 439038 | Ubuntu user 20892

  2. #2
    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]
    Linux user 439038 | Ubuntu user 20892

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts