Dear folks, Presently a rewrite should redirect

/index.php to /en/home

And for your this works fine through the following rule:

RewriteRule ^index.php /en/home [R=301]

However, when /someotherfolder/index.php is known as, even so it redirects to /en/home while it shouldn't! How do i hardcode it to simply rewrite, around the condition that it is the main-index.php file, and not simply any index.php file relaxing in other much deeper folders?

Thanks greatly for the suggestions! Much appreciated.

the very best to debug RewriteRule, would be to switch on logging from the rewrite process.

<VirtualHost x.x.x.x>


  RewriteEngine On
  RewriteLog "/var/log/httpd/rewrite_log"
  RewriteLogLevel 3

  RewriteRule .....................


One question, may be the RewriteRule inside a VirtualHost section or inside a Directory section ?


this is a working sample, hope this can help.

RewriteLog "/var/log/httpd/rewrite_log"
RewriteLogLevel 3

Alias / /tmp/

<Directory /tmp/>
  Options FollowSymLinks
  RewriteEngine On
  RewriteRule ^index.htm /en/somepage [R=301]

Basically use "http://127...1/" it will get rewritten to "http://127...1/en/somepage"

(3) [perdir /tmp/] strip per-dir prefix: /tmp/ -> index.htm
(3) [perdir /tmp/] applying pattern '^index.htm' to uri 'index.htm'
(2) [perdir /tmp/] rewrite 'index.htm' -> '/en/somepage'
(2) [perdir /tmp/] explicitly forcing redirect with
(1) [perdir /tmp/] escaping for redirect
(1) [perdir /tmp/] redirect to [REDIRECT/301]

Basically use "http://127...1/" it does not get rewritten

(3) [perdir /tmp/] add path info postfix: /tmp/ -> /tmp/
(3) [perdir /tmp/] strip per-dir prefix: /tmp/ -> someotherfolder/index.htm
(3) [perdir /tmp/] applying pattern '^index.htm' to uri 'someotherfolder/index.htm'
(1) [perdir /tmp/] pass through /tmp/