You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Chris Arnold <ca...@electrichendrix.com> on 2013/04/07 01:07:41 UTC
[users@httpd] Trying to Rewrite Subdomain
Apache 2.2.12. I am trying to rewrite a subdomain like so:
http://sub.domain.com to http://sub.domain.com/"alias".
Here is the alias conf:
Alias /"alias" /path/to/root/directory
<Directory /path/to/root/directory>
Options FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
DirectoryIndex index.php
php_admin_flag magic_quotes_gpc Off
</Directory>
I made a virtualhost file in vhost.conf directory like so:
<VirtualHost *:80>
ServerName sub.domain.com
RewriteCond %{HTTP_HOST} ^sub.domain.com [NC]
RewriteCond %{REQUEST_URI} !^/"alias"/
RewriteRule ^(.*) http://sub.domain.com/"alias"/ [L]
</VirtualHost>
When going to http://sub.domain.com, i get a 403:
[Sat Apr 06 18:44:34 2013] [error] [client ip] Directory index forbidden by Options directive: /srv/www/htdocs/
First, are the rewrite rules correct for what i am trying to do? Second, should they be included in the "alias" file to work?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Trying to Rewrite Subdomain
Posted by Chris Arnold <ca...@electrichendrix.com>.
>Apache 2.2.12. I am trying to rewrite a subdomain like so:
>http://sub.domain.com to http://sub.domain.com/"alias".
>Here is the alias conf:
>
>Alias /"alias" /path/to/root/directory
><Directory /path/to/root/directory>
> Options FollowSymLinks
> AllowOverride None
> Order allow,deny
> allow from all
> DirectoryIndex index.php
> php_admin_flag magic_quotes_gpc Off
></Directory>
>
>I made a virtualhost file in vhost.conf directory like so:
>
><VirtualHost *:80>
> ServerName sub.domain.com
>
> RewriteCond %{HTTP_HOST} ^sub.domain.com [NC]
> RewriteCond %{REQUEST_URI} !^/"alias"/
> RewriteRule ^(.*) http://sub.domain.com/"alias"/ [L]
>
></VirtualHost>
>
>When going to http://sub.domain.com, i get a 403:
>[Sat Apr 06 18:44:34 2013] [error] [client ip] Directory index forbidden by Options directive: /srv/www/htdocs/
>
>First, are the rewrite rules correct for what i am trying to do? Second, should they be included in the "alias" file >to work?
I got this to work by putting a redirectmatch in the alias file, like so:
ServerName sub.domain.com
RedirectMatch ^/$ http://sub.domain.com/alias/
Alias /alias /path/to/root/directory
<Directory /path/to/root/directory>
Options FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
DirectoryIndex index.php
php_admin_flag magic_quotes_gpc Off
</Directory>
Is there a way to configure this to answer for any domain? The apps. part will always stay the same but the domain part will change. A wildcard of sorts. So, http://apps.domain1.tld, http://apps.domain2.tld and so on; this conf file would answer for any http://apps.domain.tld request.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org