I have the following .HTACCESS:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
The problem is then when I try and put an image in the webpage, or include a CSS or JS file in the <head> tag, it routes everything through to my index.php. How can I prevent/work around this?
The aim is to have all traffic directed to my index, i.e. when the given URL is domain.com/shop or domain.com/signup then they would be taken to shop.php or signup.php respectively. The problem is when including images and the like the routing through to index.php screws it over. If I simply have an image tag:
<img src="/img/foobar.jpg"> Then the image tries to load index.php with the attributes /img/foobar.jpg. Which is not what I want to do.
The only solution I can think of is to hardode the URL in for every image. i.e.
<img src="<?=HARDREF;?>/image.jpg">
1 Answer