Using mod_rewrite() on 1and1 shared hosting
<p><strong>Update</strong></p>

<p>I couldn't get this to work adding rules to the .htaccess file, in the end I used the Wordpress Rewrite class and added an add_rewrite_rule() to do the re-write which worked perfectly.</p>

<p><strong>Original Post</strong></p>

<p>I have been trying to put together a <code>.htaccess</code> rule to move parts of the path to a query string. As per <a href="https://wiki.apache.org/httpd/RewritePathInfo" rel="nofollow">https://wiki.apache.org/httpd/RewritePathInfo</a>.</p>

<p>I have two folders in the root of my webspace, one for <code>www.mydomain.com</code> and one for <code>test.mydomain.com</code>. My <code>.htaccess</code> file is in the <code>test.mydomain.com</code> folder, and I want to rewrite <code>test.mydomain.com/images/parm1/parm2</code> to <code>test.mydomain.com/images/?gwpw=parm2&amp;gwpi=parm1</code>.</p>

<p>If I put garbage in the <code>.htaccess</code> file I get a 500 internal server error so I know the file is being read. I also have some existing rules in <code>.htaccess</code> from Wordpress that use <code>mod_rewrite()</code>, which if I comment out, stop the site redirecting to a 404 error page if you try to access <code>test.mydomain.com/somegarbage</code>. So I know <code>mod_rewrite()</code> is enabled.</p>

<p>I have read I need to set <code>Options +FollowSymLinks -MultiViews</code>, so the whole rule I have is:</p>

<pre><code>Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^/images/([^/]*)/([^/]*) /images/?gwpw=$1&amp;gwpi=$2 [PT]
</code></pre>

<p>I have tried this in different parts of the file, removing the leading slash from <code>/images/?gwpw=...</code>. I've tried adding a rule that I thought should rewrite every request to a different page like <code>RewriteRule ^/* /somewhere</code> but I can't seem to get any rewrite to work.</p>

<p>As this is a shared server I can't access <code>httpd.conf</code>.</p>

<p>My entire .htaccess file currently looks like this:</p>

<pre><code>&lt;IfModule php5_module&gt;
    php_flag session.cookie_httponly on
&lt;/IfModule&gt;

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^/images/([^/]*)/([^/]*) /images/?gwpw=$1&amp;gwpi=$2 [PT]

# BEGIN WordPress
&lt;IfModule mod_rewrite.c&gt;
RewriteEngine On

RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

&lt;/IfModule&gt;

# END WordPress

# Wordfence WAF
&lt;Files ".user.ini"&gt;
&lt;IfModule mod_authz_core.c&gt;
    Require all denied
&lt;/IfModule&gt;
&lt;IfModule !mod_authz_core.c&gt;
    Order deny,allow
    Deny from all
&lt;/IfModule&gt;
&lt;/Files&gt;
</code></pre>

<p>I am a complete newbie when it comes to .htaccess rules, so any help would be greatly appreciated. I'm clearly doing something wrong but I can't see the wood for the trees anymore!</p>