1

I am setting up a Magento website which is not inside of any sub-directory such as /shop.

Before every URL on the website had the index.php append next to the domain name, for e.g the admin panel was example.com/index.php/admin.

I enabled Mod_rewrite in Magento's admin panel and added an .htaccess file with the following to make sure that example.com/admin actually goes to the admin panel and so on. It does work.

Here's the htaccess configuration:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

The problem is that when I manually type example.com/index.php/admin it takes me to the admin panel as expected but the URL stays that, I expected it to redirect to the right URL which is example.com/admin but I am not able to.

Do I have to add any configurations to the htaccess or is it Magento related?

0

1 Answer 1

3

You can use the following rewrite rules to do this:

RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

This will check if the url contains index.php and if it does then redirect to the url without index.php.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.