Mod Rewrite - Virtual Host

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Mod Rewrite - Virtual Host

Postby grimbone » 14. August 2006 01:55

Hi,

I am using XAMPP version 1.5.3a in Windows XP and cannot figure out how to get friendly URL's working with virtual host. I have enabled the Friendly URLs feature (If your server is running off of apache and has Mod Rewrite enabled, then you can turn this setting on to make your URLs more user friendly) in my the Subdreamer CMS control panel. I have removed the # from the LoadModule rewrite_module modules/mod_rewrite.so in my httpd.conf to enable Mod Rewrite.

I have also changed in my httpd.conf to allow overide all.

This is what my httpd-vhosts.conf looks like for virtual hosts...

Code: Select all
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your<br>
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#

<VirtualHost *:80>
ServerAdmin admin@gamerquest.com
DocumentRoot "C:/Program Files/xampp/htdocs/www/GamerQuest"
ServerName gamerquest.com
ServerAlias www.gamerquest.com
</VirtualHost>


I keep getting an error 404 when i try my links with Friendly Urls enabled and my error log states...

Code: Select all
[Sun Aug 13 12:49:41 2006] [error] [client xx.xxx.xxx.xx] File does not exist: C:/Program Files/xampp/htdocs/www/GamerQuest/gallery, referer: http://www.gamerquest.com/


If i disable the Friendly URLs in my Subdreamer CMS everythng works fine (as far as Virtual Hosts go) but friendly URLs do not show.

Any ideas on what my problem might be?
Last edited by grimbone on 14. August 2006 07:33, edited 1 time in total.
grimbone
 
Posts: 3
Joined: 14. August 2006 01:35

Postby Izzy » 14. August 2006 03:01

grimbone wrote:I have also changed in my httpd.conf to allow overide all, this is my httpd.conf below...

This is only applicable to the default settings in the httpd.conf file.
Code: Select all
<Directory "C:/Program Files/xampp/htdocs">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options -Indexes FollowSymLinks Includes ExecCGI
   
    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all

</Directory>

So it only affects C:/Program Files/xampp/htdocs

In your virtual host containers you have to change that default behavior for each virtual host as the directories will be different in each case.
Code: Select all
<VirtualHost *:80>
ServerAdmin admin@gamerquest.com
DocumentRoot "C:/Program Files/xampp/htdocs/www/GamerQuest"
ServerName gamerquest.com
ServerAlias www.gamerquest.com
<Directory "C:/Program Files/xampp/htdocs/www/GamerQuest">
Options -Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

#Repeat for your other vhosts


More reading on mod_rewrite just to know what you are dealing with and how to implement it in other situations (.htaccess etc.) can be found here:
http://httpd.apache.org/docs/2.0/rewrite/
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby grimbone » 14. August 2006 06:39

I really appreciate all the help!

Izzy wrote:In your virtual host containers you have to change that default behavior for each virtual host as the directories will be different in each case.
Code: Select all
<VirtualHost *:80>
ServerAdmin admin@gamerquest.com
DocumentRoot "C:/Program Files/xampp/htdocs/www/GamerQuest"
ServerName gamerquest.com
ServerAlias www.gamerquest.com
<Directory "C:/Program Files/xampp/htdocs/www/GamerQuest">
Options -Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

#Repeat for your other vhosts


I have made the exact changes above to my httpd-vhosts.conf that you have layed out and i am still receiving the 404 error for some reason.

This is what my error log is showing...

Code: Select all
[Mon Aug 14 01:37:31 2006] [error] [client xx.xxx.xxx.xx] File does not exist: C:/Program Files/xampp/htdocs/www/GamerQuest/gallery, referer: http://www.gamerquest.com/


Also this is what my htaccess.txt that resides in my C:/Program Files/xampp/htdocs/www/GamerQuest looks like...

Code: Select all
Options All -Indexes
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php


Did i miss something?
Last edited by grimbone on 14. August 2006 07:31, edited 2 times in total.
grimbone
 
Posts: 3
Joined: 14. August 2006 01:35

Postby Izzy » 14. August 2006 07:08

C:/Program Files/xampp/htdocs/www/GamerQuest/gallery

Do these directories exsist and is the case correct?

The htaccess.txt file should be renamed to .htaccess

It is only named htaccess.txt because Windows has a problem with files with no name only a file extension.

In your text editor click on save as .htaccess and it should save without windows chucking a wobbly.

This is duplicated now in your directory container in the httpd-vhosts.conf so you can remove it from the .htaccess file or the conf file.
Last edited by Izzy on 14. August 2006 07:33, edited 1 time in total.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby grimbone » 14. August 2006 07:28

You are correct my friend!

First i had to change my htaccess.txt to .htaccess

then i added RewriteBase /

Thanks for the help everyone, much appreciated!
grimbone
 
Posts: 3
Joined: 14. August 2006 01:35


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 125 guests