How to enable URL rewriting using the Turnkey Linux LAMP stack

johna by | December 27, 2023 | Website Hosting

This post is a follow-up to my original post on How to set up a website and database using the Turnkey Linux LAMP stack.

If you want to use an .htaccess file to manage URL rewriting on your Turnkey Linux LAMP stack server, there are a few steps you will need to perform to make this work.

First you must enable mod_rewrite for Apache.

Log in it to Webmin and press Command Shell from the Tools menu.

Enter the following command then press Execute command.

a2enmod rewrite

Command Shell


Next you need to allow overrides so that Apache will allow URL rewrite rules in a .htaccess file.

In the Servers menu, press Apache Webserver and then find your website in the list of existing virtual hosts and press the edit button (globe icon).

Apache Webserver

Then from the Virtual Server Options page press Edit Directives.

Virtual Server Options

Add the following line inside of the Directory section:

AllowOverride All

Edit Directives

Finally you can create a .htaccess file in your website folder with the rewrite rules you need. Following is an example that will load the index.php page for any request for a file or folder that does not exist.

Options FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]

Make sure you include the first line, Options FollowSymLinks.

Related Posts

Website Hosting Web Development

How to set up a website and database using the Turnkey Linux LAMP stack

by johna | November 18, 2023
If you need to host your own website for the purposes of web development, Turnkey Linux LAMP Stack is an easy to install all-in-one solution that you can set up on a spare computer or a VM (Virtual Machine).

Website Hosting

Best value Windows shared hosting - ASPnix review

by johna | April 1, 2023
My experience with ASPnix web hosting over the last ten years.

Email Website Hosting

Telstra BigPond and the message content rejected due to suspected spam error

by johna | December 9, 2020
A rant about Telstra's anti-small business mail server blacklisting policies.

Comments

There are no comments yet. Be the first to leave a comment!

Leave a Comment

About

...random postings about web development and programming, Internet, computers and electronics topics.

I recommend ASPnix for web hosting and Crazy Domains for domain registration.

Subscribe

Get the latest posts delivered to your inbox.