Linux Apache2

mod-rewrite test

Rewrites can ether be controlled from the main apache.conf or from a .htaccess file in the web root. Testing can be done with the files below (from BOLT CRM):-

.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^.*$ htaccess_tester.html
</IfModule>

Explaination… ^.*$ is anchored to the start of a line with ^, the dot matches any character and the * wildcards any number of matches up to the line end denoted by $, so this redirects any request to the url following (htaccess_tester.html).

htaccess_tester.html
 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>mod-rewrite and htaccess tester.</title>
</head>
 
<body id="home">
If you can see this, you have been rewritten correctly.
 
</body>
</html>
 
linux/linux-apache2.txt · Last modified: 09/01/2021 23:28 by andrew