# Redirect index.php

**URL:** <https://forum.getkirby.com/t/redirect-index-php/4404>\
**Category:** Questions\
**Tags:** v2\
**Created:** [June 13, 2016, 1:23pm UTC](https://forum.getkirby.com/t/redirect-index-php/4404 "2016-06-13T13:23:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jensfranke](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jensfranke/32/722_2.png) [@jensfranke](https://forum.getkirby.com/u/jensfranke)\
**Post date:** [June 13, 2016, 1:23pm UTC](https://forum.getkirby.com/t/redirect-index-php/4404/1 "2016-06-13T13:23:02Z")

</div>

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 [http://domain.de/xyz](http://domain.de/xyz) Kirby redirects to the `https://www.domain.de/index.php`. 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:

```auto
RewriteRule ^index.php$ https://www.domain.de [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?

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [June 13, 2016, 1:39pm UTC](https://forum.getkirby.com/t/redirect-index-php/4404/2 "2016-06-13T13:39:33Z")

</div>

But shouldn’t `http://domain.de/xyz` redirect to `https://www.domain.de/xyz` instead of the homepage?

You can use the following `RewriteRules` to achieve this:

```auto
# 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]

```

---

<div class="post-metadata">

**Author:** ![jensfranke](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jensfranke/32/722_2.png) [@jensfranke](https://forum.getkirby.com/u/jensfranke)\
**Post date:** [June 13, 2016, 1:55pm UTC](https://forum.getkirby.com/t/redirect-index-php/4404/3 "2016-06-13T13:55:10Z")

</div>

Ah, thanks!

> But shouldn’t [http://domain.de/xyz](http://domain.de/xyz) redirect to [https://www.domain.de/xyz](https://www.domain.de/xyz) instead of the homepage?

Sure, it would be great. 🙂

I will test your version asap.

My current approach was:

```auto
# 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} !=127.0.0.1
RewriteCond %{SERVER_ADDR} !=::1
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

```

Source: [https://github.com/h5bp/server-configs-apache/blob/master/dist/.htaccess#L345-L385](https://github.com/h5bp/server-configs-apache/blob/master/dist/.htaccess#L345-L385)

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 4:57pm UTC](https://forum.getkirby.com/t/redirect-index-php/4404/4 "2025-02-06T16:57:47Z")

</div>

Archived on February 6, 2025, 4:57pm UTC


