Redirecting old URLs to index.php


what do I have to do, to redirect the user to the index.php, when he is entering an old URL which isn’t existing anymore. I tried redirect 301 in the htacces file but it didn’t work.

Right now, if someone enters an old URL, Kirby loads the default template with header and footer and no content. But it should load the index.php. How can I get that?

Thank you.

What did you put into your htaccess? It is better to use a 302, btw, instead of a 301, but that’s just on a side note.

You probably want to redirect to a specific URL, not the index.php

I want, if someone enters (URL from old wordpress installation) the user gets directed to the homepage. In the htaccess I tried to redirect every old URL to the new but it did not work like this:

Redirect 301 /home/timo-klos
Redirect 301 /home/timo-klos
Redirect 301 /home/kunst/bucher-books

I also tried to put in the whole URL instead of /home/kunst/bucher-books

When I look at Apache docs: Redirect Directive I get:

The `Redirect` directive maps an old URL into a new one by asking the client to refetch the resource at the new location.

The old *URL-path* is a case-sensitive (%-decoded) path beginning with a slash. A relative path is not allowed.

I think your code (the old URL-path) is not correct.

In addition to that, you are mixing Redirect directives, which are loaded and executed by the mod_alias module, with the existing RewriteRule directives, which are coming from mod_rewrite. Mixing both of these is not recommended by Apache and if you do it anyway, their placement in the config is important:

when there are Redirect and RewriteRule directives in the same scope, the RewriteRule directives will run first, regardless of the order of appearance in the configuration file

Note that the ordering of directives alone is not the key, but you have to take into account the scope of your directives, which will be merged together by Apache after loading all config files, being it the main config, any other additional config or the .htaccess file (or even multiple .htaccess files if this is the case).

If you have access to your logfiles, you can try to increase the LogLevel to investigate whats happening.

Thanks for the replies. Changing the URLs worked!