PDA

View Full Version : apache rewrite problem



sunzon
05-19-2005, 11:39 AM
Is some extra configuration required to use a rewrite in a htacess file for a virtual domain?

I am sure my coding is correct since it is the same setup as I am using on my main domain, where it works fine, but the rewrite is simply ignored in the virtualhost.



Options FollowSymLinks

RewriteEngine On
RewriteRule ^([0-9a-zA-Z]+).html /cgi-bin/dir/program.cgi?ID=$1 [L]


Any ideas?

jalal
05-19-2005, 01:34 PM
AllowOverride All

needs to be set for that domain. Maybe check that and set it specifically if it isn't.

Also check the access_log/error_log and see if there are any pertinent messages.

HTH

sunzon
05-19-2005, 01:51 PM
Thanks Jalal

I had checked errorlog, it just says filenotfound (doesn't execute the rewrite).

Where to place the AllowOverride All ?

the virtualhost is loacted at var/www/vhosts/myvirtualhostname (viz not below var/www/html)

wildjokerdesign
05-19-2005, 02:18 PM
Place the AllowOverride All within your VirtualHost tag for the secondomain and wrap it in the Directory tag.



<VirtualHost *>
ServerName myvirtualhostname
ServerAlias myvirtualhostname
DocumentRoot /var/www/vhosts/myvirtualhostname

<Directory "/var/www/vhosts/myvirtualhostname">
Options FollowSymLinks MultiViews Includes ExecCGI
AddHandler cgi-script .cgi .pl .py .sh
AllowOverride All
Order allow,deny
Allow from all
</Directory>

</VirtualHost>
Any time you make the document root above /var/www/html you pretty much have to do this to get things to work like they do for your main domain. I have added in some other things that may catch you up. It is just a matter of looking at how the main domain is configed and setting up your VH the same.

sunzon
05-19-2005, 02:29 PM
thanks very much.
That did the trick :D

However it was not necessary to do it for each virtual host.
I simply made an overall instruction for the "/www/vhosts" location just like the general "/www/htdocs"


<Directory "/www/htdocs">
Options FollowSymLinks MultiViews Includes ExecCGI
</Directory>

<Directory "/www/vhosts">
Options FollowSymLinks MultiViews Includes ExecCGI
AddHandler cgi-script .cgi .pl .py .sh
AllowOverride All
Order allow,deny
Allow from all
</Directory>