I’m making a .htaccess for my web page, here’s the code:
Options -Indexes
RewriteEngine On
RewriteRule ^([A-Za-z]+)/([0-9]+)/$ files.php?row=$1&column=$2
RewriteRule ^([A-Za-z]+)/?$ $1/1/
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mywebpage\.at [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} ^http://.*$
RewriteRule \.(jpe?g|gif|bmp|png)$ /imgs/hotlinks.png [L]
RewriteCond %(REQUEST_URI) ^imgs/$ [NC]
RewriteRule / - [F]
ErrorDocument 404 /404.html
ErrorDocument 403 /403.html
The problem is, my images are not showing up in pages with rewritten URLs. Apparently, their routes are also affected by the rewriting. Simply explained: an image located at http://www.mywebpage.at/imgs/pic1.jpg loads on http://www.mywebpage.at/files.php?row=first&column=3, but when I try to enter http://www.mywebpage.at/first/3/ the browser looks for the image in http://www.mywebpage.at/first/3/imgs/pic1.jpg, and obviously fails to load it.
How can I fix this so that the routes of the images do not change, no matter from where I use them?
You can do:
That will rewrite everything except the imgs folder.
Edit: Apologies, misread question.
Make your image paths absolute. E.g. relative path is:
Absolute path is:
The slash at the beginning tells it to go to the very root of the site and then go to imgs, then image1.jpg.