Redirect everything to homepage (except single pages)

1 minute read Modified:

Use Apache redirects to send all requests to homepage.

If you want to send all requests to a site to the homepage, use this Apache directive.

Keep in mind that requests to an asset directory (images, CSS or similar) must be excluded from the redirect rule. In the same manner, you can exclude single pages that should not be redirected.

Add to .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !/impressum.html$
RewriteCond %{REQUEST_URI} !/datenschutz.html$
RewriteCond %{REQUEST_URI} !/assets/
RewriteRule (.*) / [R=301,L]