I want to create flat links for my website. The .htaccess
code is following:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9A-Za-z]+)?$ /index.php?page=$1 [L]
RewriteRule ^([0-9A-Za-z]+)/?$ /index.php?page=$1 [L]
</IfModule>`
Now my website is working which can be seen through print_r($_GET)
and getting all the values.
My website has a code like this: <img src="images/icons/image.png" />
, where the image resides on path: /images/icons/up.png
.
Now I can visit my website as: http://somedomain.com/home
and everything works fine. But when I put: http://somedomain.com/home/
, it gets stuck.
The image gets a path like this for the browser: http://somedomain.com/home/images/icons/image.png
which is not available and it should be: http://somedomain.com/images/icons/image.png
.
How to solve this?
It would helpful if there is any solution by modifying the .htaccess as I want to use relative paths for all links and not full path.
Thanks to Ben Clifford for your help. According to him if I redirect the second rule one to the format like the first one and not over index.php. Then it should work.