1

What's happening:

domain.com/abc/index.php/xyz gets redirected to www.domain.com/abc/index.php/xyz

I'd like:

domain.com/abc/index.php/xyz gets redirected to www.domain.com/abc/xyz

In the document root directory of a Magento installation, I have the following to redirect domain.com/... to www.domain.com/..., and index.php is never there.

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L]

However, there's a sub-directory that contains static pages at root/abc. This directory has its own .htaccess file, and I've put the same rewrite condition and rule as above. It also have the following. I'm not sure what the first two conditions are doing. The RewriteRule seems like it should remove the index.php.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /corps/index.php/$1 [L]

Any ideas?

2

Check this guide, it has the solution for your issue. You have to change your .htaccess to have this inside:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
  • Does this work for the subdirectory of the root? FYI, I already have index.php removed from all URLs except for the domain.com/abc/index.php/.... – musicliftsme Jun 17 '14 at 18:48
  • I think they need RewriteBase /abc/ – Steve Robbins Oct 3 '14 at 23:08
  • If one also wants to redirect /index.php/ URLs to URLs without it, then see this: stackoverflow.com/questions/47833648/… – Deepak Kamat Dec 15 '17 at 14:02
1

The 3th line from

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /corps/index.php/$1 [L]

causes the url to have index.php in it. The first 2 lines ensure existing files and directories are not redirected.

Change it to below and you should be good

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /corps/$1 [L]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.