0
  1. I have a rewrite rule to hide index.php, which is working fine.

    RewriteCond $1 !^(index\.php) 
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]
    
  2. I am currently redirecting a specific sub-domain to another domain.

    RewriteCond %{HTTP_HOST} ^(www\.)?deutschland\.example\.com$ [NC]
    RewriteRule ^ http://www.example.de%{REQUEST_URI} [NE,R=301,L]
    

The redirect is working fine, but now I am getting index.php in the URL too, which is coming in the REQUEST_URI.

http://www.example.de/index.php/search/result

So how to remove 'index.php' from this redirected URL? Note: Its the same php website application only, just using country-wise multiple domains.

Girish
  • 11,907
  • 3
  • 34
  • 51

1 Answers1

1

(1) Rule order is important. (2) the last flag doesn't mean last; it means last on this cycle. (From Apache 2.4 the end flag does what you might think last does. See my Tips for debugging .htaccess rewrite rules for more discussion of this). So in this case rule(1) fires and then mod_rewrite loops around again and this time rule (2) fires giving what you find.

Swap the two rules around and it will work as expected.

Community
  • 1
  • 1
TerryE
  • 10,724
  • 5
  • 26
  • 48