You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Paolo De Michele <pa...@paolodemichele.it> on 2014/06/16 23:13:49 UTC
[users@httpd] - customize .htaccess
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
regards
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
[users@httpd] [SOLVED] [users@httpd] - customize .htaccess
Posted by Paolo De Michele <pa...@paolodemichele.it>.
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 - rbowen@rcbowen.com - @rbowen
> http://apachecon.com/ - @apachecon
Re: [users@httpd] - customize .htaccess
Posted by Rich Bowen <rb...@rcbowen.com>.
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.
--
Rich Bowen - rbowen@rcbowen.com - @rbowen
http://apachecon.com/ - @apachecon
Re: [users@httpd] - customize .htaccess
Posted by Paolo De Michele <pa...@paolodemichele.it>.
any idea?
someone has tried that before?
let me know, thank you in advance
On 17/06/14 07:56, Cain Dickens wrote:
>
> you can try to make use of virtualhost , each domain has its solely
> directory and make than dir as its root DIR .
>
> Cain
>
> 2014-6-17 上午5:14于 "Paolo De Michele" <paolo@paolodemichele.it
> <ma...@paolodemichele.it>> 写道:
>
> hi guys,
>
> I would like to customize .htaccess
> my scenario should be:
>
> - domain.com <http://domain.com>
> - sub.domain.com <http://sub.domain.com>
> - sub2.domain.com <http://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 <http://sub.domain.com> or
> sub2.domain.com <http://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 <http://sub.domain.com> the link
> return to sub.domain.com/sub/ <http://sub.domain.com/sub/>
> it works correctly but I would like to see only sub.domain.com/
> <http://sub.domain.com/> without
> sub directory
>
> how can I personalize it in the .htaccess?
> thanks in advance
>
> regards
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> <ma...@httpd.apache.org>
> For additional commands, e-mail: users-help@httpd.apache.org
> <ma...@httpd.apache.org>
>
Re: [users@httpd] - customize .htaccess
Posted by Cain Dickens <ca...@gmail.com>.
you can try to make use of virtualhost , each domain has its solely
directory and make than dir as its root DIR .
Cain
2014-6-17 上午5:14于 "Paolo De Michele" <pa...@paolodemichele.it>写道:
> 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
>
> regards
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>