Monday , February 3 2025

301 redirect from index.php except admin folder

Description of the problem – if you add a standard redirect from index.php to the root of the site, this rule will by default apply to the site admins. For Joomla and Вitrix, the result will be the inability to log in to the admin panel, because the index will be redirected to the root of the site.

Here is an example of a redirect for Bitrix from index.php except the /bitrix/ folder:

RewriteCond %{REQUEST_URI} ^(.*)index\.php$ [NC]
RewriteCond %{REQUEST_URI} !bitrix [NC]
RewriteCond %{REQUEST_METHOD} get [NC]
RewriteRule ^(.*)index\.php$ %1 [R=301,NC,L]

A similar example for a Joomla redirect from index.php except the /administrator/ folder:

RewriteCond %{REQUEST_URI} ^(.*)index\.php$ [NC]
RewriteCond %{REQUEST_URI} !administrator [NC]
RewriteCond %{REQUEST_METHOD} get [NC]
RewriteRule ^(.*)index\.php$ %1 [R=301,NC,L]

About iryna

I'm Iryna, a web developer from Ukraine with a decade of experience solving complex technical challenges in the world of freelance. Throughout my career, I've worked on everything from troubleshooting server-side issues and optimizing website performance to enhancing user interfaces. On this blog, I share detailed solutions to the technical problems I’ve encountered and methods that have worked best for me. In addition to my technical expertise, I’m also passionate about digital drawing. I hope the tutorials and insights I provide here will help both fellow developers and creatives alike in their own projects.

Check Also

301 redirect in .htaccess from uppercase to lowercase characters

In web development, managing URL consistency is crucial for SEO and user experience. One common …

Leave a Reply

Your email address will not be published. Required fields are marked *