This is because your rewrite rule only does internal rewriting and doesn't redirect the browser to that URL. Therefore the browser is still on page www.example.com/some_text/exampelFile
; all the relative links and locations in the HTML of your exampelFile.php
are relative to that location, not to the actual file location, as they are obtained by the browser.
You could prevent this by making it a redirect with RewriteRule
's flag R
:
'redirect|R [=code]'
(force redirect)
Prefix Substitution with
http://thishost[:thisport]/
(which makes the new URL a URI) to force a
external redirection. If no code is given, a HTTP response of 302
(MOVED TEMPORARILY) will be returned.
Resulting:
RewriteEngine on
RewriteRule ^(.*)/exampelFile /exampelFile.php?data=$1 [L,R=301]