mod_rewrite only on GET

From the docs:

  • Server-Variables: These are variables of the form %{ NAME_OF_VARIABLE } where NAME_OF_VARIABLE can be a string taken from the following list:

    ...

connection & request:
...
REQUEST_METHOD

So, yeah. Use RewriteCond with that server variable.


I'd recommend being explicit and only firing the RewriteRule when the request method is GET, rather than whenever it's not POST as there are numerous other methods. So your rewrite condition could look like this:

RewriteCond %{REQUEST_METHOD}  =GET

RewriteRule    ^index\.php$  index.php?module=Home&action=index

Add this condition...

RewriteCond %{REQUEST_METHOD} !POST

...to not match POST requests.


This works fine for GET requests...

RewriteCond %{REQUEST_METHOD} ^GET [NC]