I am getting a 404 not found when doing a mod rewrite in my htaccess file, accessing localhost

How can I get this to work, all references I found point me to edit a file in /etc/apache2/mods-enabled

for me there is no /etc/apache2 folder, where is apache installed then?

using xampp, http://www.apachefriends.org/en/xampp-linux.html

  • Any help on this? – Marchosius Sep 6 '12 at 7:24

You have asked question for xampp in your title but you have described apache2 problem in decription. Both are different methods to run apache web server.

xampp configuration is different than apache2. xampp contains apache and mysql inside it, if you have installed xampp, you don't need to install them separately.

xampp does not identify a2enmod or a2dismod, even you have installed xampp in ubuntu. They (a2enmod or a2dismod) have been configured for apache2.

The configuration of xampp is very much similar like httpd of centOS or fedora.

XAMPP is installed as /opt/lampp. Rewrite modules are enabled by default in xampp. You can check it in the file /opt/lampp/etc/httpd.conf. There should be line

LoadModule rewrite_module modules/mod_rewrite.so

there in the file httpd.conf as well as mod_rewrite.so file is available in modules. If line is commented, it means module is disabled. The line should be uncommented as well as .so file should not be corrupted if you want to use rewrite rules in xampp.

| improve this answer | |

Don't forget after setting in httpd.conf in this section:

<Directory />
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all

you should enable mod_rewrite:

sudo a2enmod rewrite

and then restart apache:

sudo service apache2 restart

To ensure that, you can check from phpinfo in Configuration > apache2handler > Loaded Modules there must be written mod_rewrite and it means mod_rewrite is enabled. Hope it can help.

| improve this answer | |

I'm not sure whether XAMPP actually has the sites-available/sites-enabled, mods-available/mods-enabled structure that the Ubuntu Apache packages use. But if those directories are there, I would expect them to be somewhere in /opt/lampp/etc, because the main config file httpd.conf is there (according to http://www.apachefriends.org/en/xampp-linux.html#385).

According to some (quite dated) blog entries on XAMPP, there might be a fitting LoadModule directive in that httpd.conf, something to the effect of

#LoadModule rewrite_module path/to/mod_rewrite.so

If this is still current, you need to remove the comment symbol (#) from that line. Additionally, you need to enable local overriding of the central settings (for example from a htaccess file or a vhost). So you need to look for

AllowOverride None

and change it to

AllowOverride All

That may appear in the httpd.conf more than once, you need to adjust every occurence. After the next restart of Apache mod_rewrite should be working.

At the end of the day, the mod-available/mod-enabled system is "just" a conventient way to manage configuration snippets like the LoadModule above, see for example /etc/apache2/mods-available/rewrite.load from the Ubuntu Apache packages).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.