Mobile app version of vmapp.org
Login or Join
Ann8826881

: Mod_rewrite doesn't work at all I have my small website (made for study purposes) on localhost and I am trying to get .htaccess working (note that I am a complete beginner to .htaccess). So

@Ann8826881

Posted in: #Apache2 #ModRewrite

I have my small website (made for study purposes) on localhost and I am trying to get .htaccess working (note that I am a complete beginner to .htaccess). So far, I have discovered that .htaccess is not even read by the server (I tried creating a custom 404 page - no change).

I've got my server setup on a Raspberry Pi and I am accessing it over a local network. But even after allowing mod_rewrite using sudo a2enmod rewrite (and rebooting apache2) it still doesn't work.

Any suggestions? Ask for any additional info. I will do my best to answer it.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Ann8826881

1 Comments

Sorted by latest first Latest Oldest Best

 

@Cooney921

If your .htaccess is not being read by the server, then that's the problem you need to fix first. Enabling .htaccess files is done using the AllowOverride directive, which tells Apache to look for that file in the specified folder for additional configuration info.

If you're using the default vhost (which will be somewhere like /etc/apache2/sites-available/default), then check that file for:

AllowOverride None


and change it to:

AllowOverride All


If it appears in that file multiple times, you only want to edit the one relating to your DOCUMENT_ROOT directory.

If the line isn't in there, check your main Apache config file instead.

If you've created a new vhost, you'll need to add a new <Directory> block:

<Directory "/path/to/your/docroot">
AllowOverride All
</Directory>


Alternatively, anything you put in a .htaccess file could instead be put in the vhost itself.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme