Friday , December 20 2024

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 admin

Hi there! My name is Iryna, I am a web developer from Ukraine. While working on freelance projects I often face different technical issues and in this blog I publish articles on how to solve them. I am also interested in digital drawing and in this blog you will find brief tutorials that helped me and hopefully can help you as well.

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 *