Jump to the navigation menu

Using .htaccess with Apache

Using .htaccess with Apache

https://github.com/opdavies/oliverdavies.uk/blob/main/source/.htaccess

Using [L] after a RewriteRule makes it the last rule, so further redirects are not executed.

Using [R=301] sets the response status code, such as 301 or 302.

RewriteCond %{REQUEST_FILENAME} -d ensures the request filename is not a directory.

Wildcard redirects can be done with regex: RewriteRule ^articles/(.*) /blog/$1 [L,R=301].

Simple redirects can be done with Redirect, e.g. Redirect 301 /10-useful-drupal-6-modules-i-use-every-project /blog/10-useful-drupal-6-modules.

https://httpd.apache.org/docs/2.4/rewrite/remapping.html