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 .....................

  ...
</VirtualHost>

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

-Martin

this is a working sample, hope this can help.

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

Alias /dummy.org /tmp/dummy.org

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

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

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

Basically use "http://127...1/dummy.org/someotherfolder/index.htm" it does not get rewritten

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

-Martin