Redirect index.php

We ran in one small issue on our live-server.

We force https and www and we must use RewriteBase / on our environment. If we have a request like Kirby redirects to the Definitely one issue with our server setup, because it works in our local environment.

Currently I use the following rule at the bottom of our Redirect-Rules:

RewriteRule ^index.php$ [R=301,L]

Is there a better way to define the root as default instead of the index.php, to remove the problem with duplicated content for seo crawlers?

But shouldn’t redirect to instead of the homepage?

You can use the following RewriteRules to achieve this:

# Rewrite everything to HTTPS
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# Rewrite non-www to www
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
1 Like

Ah, thanks!

But shouldn’t redirect to instead of the homepage?

Sure, it would be great. :slight_smile:

I will test your version asap.

My current approach was:

# Redirect from the `http://` to the `https://` version of the URL.

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{SERVER_ADDR} !=
RewriteCond %{SERVER_ADDR} !=::1
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]