1

I need to Rewrite http://www.domain.net/img.php?id=example.jpg to http://www.domain.net/index.php?id=example.jpg

example.jpg is changing. I am not common with htaccess syntax. Can someone help me please?

1 Answer 1

2

Enable mod_rewrite and .htaccess through httpd.conf (if not already enabled) and then put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteRule ^img\.php$ /index.php [L,NC]

QUERY_STRING will automatically be carried over to /index.php

Sign up to request clarification or add additional context in comments.

3 Comments

Just to clarify, the section at the end of the RewriteRule, [L,NC,QSA] are flags. The L means stop processing any additional rules, the NC means process this case-insensitively, and the QSA means leave the query string intact.
QSA means query string append (actually that wasn't needed in this rule) Let me edit.
QSA is needed only when one is modifying query parameters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.