0

I'm useing this code:

RewriteEngine on
RewriteRule ^(.*)/exampelFile exampelFile.php?data=$1 [L]

and my problem is that the page dosn't load my css&js file. It seems the php page it self is getting loaded form

www.example.com/some text/exampelFile...

insted of

www.example.com/exampelFile?data=some text...

and this why it dosn't find the css&js files

1 Answers1

0

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]
Esa Jokinen
  • 52,963
  • 3
  • 95
  • 151