1

I have this rewrite rule

RewriteRule ^ar$       /index2.html

but i need to keep the url in the address bar unchanged after the redirect.
ie. if the user typed http://mydomain.com/ar i need to redirect him to /index2.html but keep the url as is.
any idea of how to do so??
Thanks for your help

Alaa Alomari
  • 638
  • 6
  • 19
  • 37

2 Answers2

1

The Pattern in the RewriteRule is wrong. A

RewriteRule ^/ar$       /index2.html

should to exactly what you want: It rewrites the /ar to index2.html without telling the web browser about the redirection.

Lairsdragon
  • 700
  • 1
  • 5
  • 21
  • ok... what shall it be... i tried too many flags like L,NC,R=301, R and too many others, but didn't get it as i want... so what shall it be?? – Alaa Alomari Mar 30 '11 at 11:37
  • No flags at all :-) Just tried on my webserver works like a charm. – Lairsdragon Mar 30 '11 at 11:39
  • this is what i know!! it is supposed to keep the url unchanged if you didn't provide any rewrite flag!! but this didn't work with me!! any idea?? – Alaa Alomari Mar 30 '11 at 11:57
  • Could it be that you dont really redirect to a static file? If another apache module is involved like mod_proxy, mod_jk etc this ma lead to an external rewrite via HTTP code 302 – Lairsdragon Mar 30 '11 at 12:16
  • @Alaa If you remove that rule completely do you still get the redirect? If so you probably have another rule or directive that is being applied first. – matthew Mar 30 '11 at 21:22
1

What Lairsdragon said is correct. However, if you have more than one rewrite rule in your config, you will want to add the [L] flag to the end in order to prevent other rules from being applied.

Pierre.Vriens
  • 1,159
  • 34
  • 15
  • 19
clmarquart
  • 456
  • 3
  • 5