.htaccess: Redirecting all URLs to the start page

Icon instructions: Redirecting all URLs to the start pageToday I had to fill an old domain with a placeholder for a customer and drag all the content to a new domain. The background is a change because of the [search engine optimization of the website-> search engine optimization]. But that's not supposed to be the topic here.

I have now looked for a way that visitors who arrive on a subpage are also redirected to the placeholder start page. I call this index.php - this is important to exclude this file from forwarding.

Here is the corresponding code for the .htaccess file:

RewriteEngine On
RewriteBase /
RewriteRule !^(.*).php$ - [C]
RewriteRule ^(.*)$ index.php [R=301,L]

For the optimization I work with 301 redirects here. If you like, you can also exclude other files such as robots.txt. To do this, just add another line after the "RewriteBase /" line, which then looks like this:

RewriteRule !^robots.txt$ - [C]

Did you like the article and did the instructions on the blog help you? Then I would be happy if you the blog via a Steady Membership or at Patreon would support.

Leave a Comment

Your e-mail address will not be published.