On 17/06/14 20:19, Rich Bowen wrote:
>
> On 06/16/2014 04:13 PM, Paolo De Michele wrote:
>> hi guys,
>>
>> I would like to customize .htaccess
>> my scenario should be:
>>
>> - domain.com
>> - sub.domain.com
>> - sub2.domain.com
>>
>> 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 sub.domain.com or sub2.domain.com 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 sub.domain.com the link return to sub.domain.com/sub/
>> it works correctly but I would like to see only sub.domain.com/ 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
> http://httpd.apache.org/docs/current/rewrite/vhosts.html  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.
>

hi Rich,

thanks so much for your help
I solved the situation about vhosts

regards
>
>
> -- 
> Rich Bowen - rbo...@rcbowen.com - @rbowen
> http://apachecon.com/ - @apachecon 

Reply via email to