Skip to content

24 ways to impress your friends

Vote down?

Stomme poes

@ Berend Bierenbroodspot

If you are on shared hosting and have no access to root, .htaccess file would be in the root dir of whatever you’re running a web page with: for example, if you are using WordPress, there’s a root WordPress directory with all the .php files and stuff. If there’s not already a file there called .htaccess, you can simply make one. The server actually running your WP stuff will probably check for it, every request (this is why .htaccess is not preferred if you have root access: https://httpd.apache.org/docs/2.2/howto/htaccess.html and is a small, but regular, performance penalty).

If you do have root access, let’s say you’re on a Debian-based machine for example… you may have files with names like /sites-enabled/default or sites-available/default under a directory called apache2 (we’re assuming you’re using Apache). At the bottom of one of those files, you can add rewrite rules, starting with “RewriteEngine on”.

If you’ve only just installed your machine or apache you may have to explicitly enable the rewrite.so stuff on, since it may be off by default. You can google/DuckDuckGo around for how to do all that, but this article is assuming the .htaccess file.