Clean URL support in XAMPP

Last modified: March 7, 2009 - 15:51

Clean URLs do not work out of the box on XAMPP 1.5.x with PHP4 due to a problem in Apache's module load order; mod_rewrite will not work properly. To remedy this you will need to edit the file [path_to_xampp]/apache/conf/httpd.conf.

mod_rewrite location

Remove the # at the beginning of this line:

LoadModule rewrite_module modules/mod_rewrite.so

and move it to just above or below
#LoadModule cache_module modules/mod_cache.so

AllowOverride

If the mod_rewrite change does not work, you also need to check that AllowOverride All is set for the directory Drupal is in. Do this in httpd.conf or extra/httpd-xampp.conf

Open up file \apache\conf\extra\httpd-xampp.conf

Put this code in:

   Alias /drupal "C:/Program Files/xampp/htdocs/drupal/"
    <Directory "C:/Program Files/xampp/htdocs/drupal">
      AllowOverride All
      Order allow,deny
      Allow from all
    </Directory>

Remember to change the path to match your installation location.

If you're not sure where to add it, it might be worth putting it under the entry

    Alias /security "C:/Program Files/xampp/security/htdocs/"
    <Directory "C:/Program Files/xampp/security/htdocs">
    ...
    ...
    </Directory>

which should already exist.

Always restart Apache after you make changes or the changes to its configuration files won't have an effect.

Drupal Directory

If Drupal is not installed in the document root, the next thing you'll have to do is modify the file .htaccess that comes with Drupal. Remove the commentsign (#) in front of RewriteBase and, if necessary, modify the path:

RewriteBase /drupal

Finally, in Drupal go to Administer » Site Configuration » Clean URLs (admin/settings/clean-urls) and run the clean URL test. Then click the "Enabled" option for Clean URLs and save the settings.

thanks, this was very

drupal_jay - April 30, 2008 - 13:43

thanks, this was very helpful. I've been banging my head for a while and these instructions came quite in handy

thanks. it seems to be very

joris.verschueren - May 6, 2008 - 13:06

thanks. it came in very handy, although I got myself into trouble with it. so, for hypercorrect newbies:

in the line
Alias /drupal "C:/Program Files/xampp/htdocs/drupal/"

only the last "drupal" must perhaps be adapted to whatever you've called the folder of your drupal installation. say, you wanted an address like http://localhost/site1 and you've changed the folder name from drupal-6.2 to site1, then this line must become

Alias /drupal "C:/Program Files/xampp/htdocs/site1/"

I hope that wasn't more confusing than helpful, but it took me quite a while to find out that this was the cause of a persisting No access - error 403 message on my locally built site and I thought maybe someone would encounter the same.

Joris

Thanks. Saved me a lot of time

Carlos Miranda Levy - June 22, 2008 - 14:33

Clean URLs worked fine on my local XAMPP installation for the default drupal site, but would not work when I tried to enable other sites with multisite. Just uncommenting the Loadmodule rewrite line and moving it up as indicated did the trick for it to work on all the multisites. Now I can replicate my server installation on my pc for proper testing... :p

------
Con paciencia y calma,
sube un burro a una palma

very helpful!

pranavsankar - November 16, 2008 - 05:15

thank you for the very helpful information.

Thanks, but still struggling

fumbling - January 24, 2009 - 04:37

Thanks, but still struggling for some reason. I tried to follow your instructions to the letter and made all the changes above, but unfortunately I still can't enable clean URLs. The only room for interpretation in your instructions seems to be in the placement of the AllowOverride code, and perhaps the RewriteBase change code. So I suspect I've made a mistake in one of those two places.

First, I'm pasting my entire file here so that there's no ambiguity on where I placed the code snippet for AllowOverride. Is it in the right place?

# XAMPP settings
#
<IfModule alias_module>
<IfModule mime_module>
    #ScriptAlias /php/ "C:/xampp/php/"
    #Action application/x-httpd-php "/php/php-cgi.exe"
    LoadModule php5_module "C:/xampp/apache/bin/php5apache2.dll"
    AddType application/x-httpd-php-source .phps
    AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml .phpt

<Directory "C:/xampp/htdocs/xampp">
<IfModule php5_module>
<Files "status.php">
php_admin_flag safe_mode off
</Files>
</IfModule>
</Directory>

    Alias /security "C:/xampp/security/htdocs/"
    <Directory "C:/xampp/security/htdocs">

<IfModule php5_module>
<Files "xamppsecurity.php">
php_admin_flag safe_mode off
</Files>
</IfModule>
        AllowOverride AuthConfig
        Order allow,deny
        Allow from all
    </Directory>


Alias /drupal "C:/xampp/htdocs/drupal/"
    <Directory "C:/xampp/htdocs/drupal">
      AllowOverride All
      Order allow,deny
      Allow from all
    </Directory>




    Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
    <Directory "C:/xampp/phpMyAdmin">
        AllowOverride AuthConfig
        Order allow,deny
        Allow from all
    </Directory>

    Alias /webalizer "C:/xampp/webalizer/"
    <Directory "C:/xampp/webalizer">
<IfModule php5_module>
<Files "webalizer.php">
php_admin_flag safe_mode off
</Files>
</IfModule>
        AllowOverride AuthConfig
        Order allow,deny
        Allow from all
    </Directory>

      Alias /contrib "C:/xampp/contrib/"
    <Directory "C:/xampp/contrib">
<IfModule php5_module>
<Files "webalizer.php">
php_admin_flag safe_mode off
</Files>
</IfModule>

        AllowOverride AuthConfig
        Order allow,deny
        Allow from all
    </Directory>
</IfModule>
</IfModule>


# Access restriction via Remote
<IfModule auth_remote_module>
    <Directory "C:/xampp/htdocs/fonts">
    AllowOverride All
    AuthType           Basic
    AuthName           "AUTH REMOTE TEST"
    AuthRemoteServer   localhost
    AuthRemotePort     80
    AuthRemoteURL      /forbidden/
    Require            valid-user
    #User: user / Password: pass
</Directory>
</IfModule>

# Access restriction via MySQL
<IfModule mysql_auth_module>
<Location /restricted>
     AuthMySQLEnable On
    AuthName "MySQL Secured Place"
    AuthType Basic
    require valid-user
    AuthMySQLHost localhost
    AuthMySQLUser root
#   AuthMySQLPassword
    AuthMySQLDB webauth
    AuthMySQLUserTable user_pwd
    AuthMySQLNameField name
    AuthMySQLPasswordField pass
    AuthMySQLPwEncryption none
</Location>
</IfModule>

Do you see a clear mistake? I edited the file at apache\config\extra rather than the one at apache\config. Would that make any difference?

Secondly, could you let me know exactly what changes I need to make for the RewriteBase change in the following section of the .htaccess file, given that the live site lives at http://localhost/drupal and the directory lives at C:\xampp\htdocs\drupal ?

# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
  # VirtualDocumentRoot and the rewrite rules are not working properly.
  # For example if your site is at http://example.com/drupal uncomment and
  # modify the following line:
  # RewriteBase /xampp/htdocs/drupal
  #
  # If your site is running in a VirtualDocumentRoot at http://example.com/,
  # uncomment the following line:
  # RewriteBase /

I tried uncommenting in both lines with RewriteBase above, and changing the path in the second case the /drupal but no dice yet.

Thanks for any help.

*_*

beautifulmind - January 24, 2009 - 04:53

Subscribing.

:)
Beautifulmind

Thanks!

bergonom - May 7, 2009 - 05:57

I was struggling with XAMPP/OSX and clean urls. Thank you!

 
 

Drupal is a registered trademark of Dries Buytaert.