I have a very simple rewrite rule which does the job: allows link domain.com/index.php?page=NAME to be displayed as domain.com/NAME.

The problem is when I try to give direct link to the image www.domain.com/static/graphics/image.png, the url rewrites to www.domain.comstatic/graphics/image.png. The slash after .com disappears and the image is not found.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?page=$1 [QSA]

Is this is problem with .htaccess or my apache configuration?

  • 2
    Do you have any other directives in your .htaccess file? Any other .htaccess files? What is the exact link to your image in your HTML? Or are you directly requesting this in the browser? – MrWhite Jun 29 '19 at 11:58

Try adding this line of code after RewriteEngine On:

RewriteBase /
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.