Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>Rule 1:</h2> <pre><code>RewriteCond %{HTTP_HOST} !^www\.(domain1|domain2|domain3|domain4)\.com [NC] RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301] </code></pre> <p>or:</p> <pre><code>RewriteCond %{HTTP_HOST} !^www\.domain1\.com [NC] RewriteCond %{HTTP_HOST} !^www\.domain2\.com [NC] RewriteCond %{HTTP_HOST} !^www\.domain3\.com [NC] RewriteCond %{HTTP_HOST} !^www\.domain4\.com [NC] RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301] </code></pre> <hr> <h2>Rule 2</h2> <p><code>http://www.mydomain.com/username</code></p> <p>to</p> <p><code>http://www.mydomain.com/file4.php?name=username</code></p> <pre><code>RewriteRule ^username$ /file4.php?name=username [QSA,NC,L] </code></pre> <p>and if you want to make it generic (with alphanum chars):</p> <pre><code>RewriteRule ^([a-z0-9]+)$ /file4.php?name=$1 [QSA,NC,L] </code></pre> <hr> <h2>Rule 3</h2> <p>Get all together:</p> <pre><code>RewriteCond %{HTTP_HOST} !^www\.(domain1|domain2|domain3|domain4)\.com [NC] RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301] RewriteRule ^([a-z0-9]+)$ /file4.php?name=$1 [QSA,NC,L] </code></pre> <p>Hope this helps.</p> <h2>Two hints:</h2> <p>Please try to use the <code>RewriteLog</code> directive: it helps you to track down such problems:</p> <pre><code># Trace: # (!) file gets big quickly, remove in prod environments: RewriteLog "/web/logs/mywebsite.rewrite.log" RewriteLogLevel 9 RewriteEngine On </code></pre> <hr> <p>My favorite tool to check for regexp:</p> <p><a href="http://www.quanetic.com/Regex" rel="nofollow">http://www.quanetic.com/Regex</a> (don't forget to choose ereg(POSIX) instead of preg(PCRE)!)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload