I'm beginning to make use of mod_rewrite and want to determine if the below can be done...

RewriteRule ^test/([^/]*)/$ /test.php?x=$1 [NC,L]

That actually works not surprisingly however, when the HTML creates I personally use relative pathways to images/stylesheets etc for example <img src="include/image.jpg" /> which now no more shows.

How do i circumvent this?

Thank You

One method to get it done would be to give a rule to skip requests that end in standard image file suffixes:

RewriteRule \.(gif|jpe?g|png|ico)$ - [NC,S=1]
RewriteRule ^test/([^/]*)/$ /test.php?x=$1 [NC,L]

You will find several options:

  • Avoid using relative pathways.
  • Give a <base> tag for your HTML.
  • Rewrite the look Web addresses too:
RewriteRule ^test/include/(.*)$ /include/$1 [NC,L]