httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rich Bowen <>
Subject Re: [users@httpd] - customize .htaccess
Date Tue, 17 Jun 2014 18:19:17 GMT

On 06/16/2014 04:13 PM, Paolo De Michele wrote:
> hi guys,
> I would like to customize .htaccess
> my scenario should be:
> -
> -
> -
> for istances, my root directory is /var/www/domain/
> into this would to insert about 2 new directories, called sub and sub2
> when a guest will digit or will want
> reindirize to correctly subdir (sub or sub2)
> this is my .htaccess:
> RewriteEngine on
>                  RewriteCond %{HTTP_HOST}   ^sub\.domain\.com$ [NC]
>                  RewriteCond %{REQUEST_URI} !^/webdav/
>                  RewriteCond %{REQUEST_URI} !^/sub/
>                  RewriteRule   ^/(.*)$ /sub/$1  [R=301,L]
> when I try to see the link return to
> it works correctly but I would like to see only without
> sub directory
> how can I personalize it in the .htaccess?
> thanks in advance

There's several possible answers to your question.

The simplest one is that you're using a [R] flag on your rule, which 
means Redirect. Redirect means "change the URL in the browser", which is 
apparently the opposite of what you want. Changing the R=301 to a PT 
*might* do what you want.

The other answer is that using .htaccess files and rewrite rules for 
virtual hosting is very error-prone, for a variety of reasons.

There's an entire document on virtualhosts with rewrite, at  Please note 
what it says at the top of that document:

mod_rewrite is not the best way to configure virtual hosts. You should 
first consider the alternatives before resorting to mod_rewrite. See 
also the "how to avoid mod_rewrite document.

Rich Bowen - - @rbowen - @apachecon

View raw message