title: trying to cover multiple redirect conditions in htaccess file
body: <p>I am trying to code an htaccess file that covers all the bases that I need, but I have a lot of quite specific actions to cover.</p>
  
  <p>I have three domains: .com .co.uk and .london and I want all traffic to end up at <a href="https://www.somepage.com" rel="nofollow noreferrer">https://www.somepage.com</a> except any traffic to .London, which has to be redirected to a specific mysite/London.php page</p>
  
  <p>So all my conditions are:</p>
  
  <pre><code>force www prefix
  force https
  remove extensions
  force .co.uk to .com domain
  force any .london traffic to specific /london page
  </code></pre>
  
  <p>So far I have:</p>
  
  <pre><code># Force WWW prefix
  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
  
  # Force SSL
  RewriteCond %{HTTPS} off
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
  
  # Remove .php extension
  RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php
  RewriteRule (.*)\.php$ /$1/ [L,R=301]
  </code></pre>
  
  <p>So I need to add the last two conditions</p>
  
  <pre><code>force .co.uk to .com domain
  force any .london traffic to specific /london page
  </code></pre>
  
  <p>But I am having difficulty getting everything to work together.</p>
  
  <p>EDIT:</p>
  
  <p>Still struggling with getting all conditions to work together, so adding some examples here for clarity.</p>
  
  <p>www.example.com -> <a href="https://www.example.com" rel="nofollow noreferrer">https://www.example.com</a></p>
  
  <p><a href="http://example.com" rel="nofollow noreferrer">http://example.com</a> -> <a href="https://www.example.com" rel="nofollow noreferrer">https://www.example.com</a></p>
  
  <p><a href="http://www.example.com/mypage.php" rel="nofollow noreferrer">http://www.example.com/mypage.php</a> -> <a href="https://www.example.com/mypage" rel="nofollow noreferrer">https://www.example.com/mypage</a></p>
  
  <p>www.example.co.uk -> <a href="https://www.example.com" rel="nofollow noreferrer">https://www.example.com</a></p>
  
  <p><a href="http://www.example.co.uk" rel="nofollow noreferrer">http://www.example.co.uk</a> -> <a href="https://www.example.com" rel="nofollow noreferrer">https://www.example.com</a></p>
  
  <p><a href="http://www.example.co.uk/mypage.php" rel="nofollow noreferrer">http://www.example.co.uk/mypage.php</a> -> <a href="https://www.example.com/mypage" rel="nofollow noreferrer">https://www.example.com/mypage</a></p>
  
  <p>www.example.london -> <a href="https://www.example.com/london" rel="nofollow noreferrer">https://www.example.com/london</a></p>
  
  <p><a href="http://example.london" rel="nofollow noreferrer">http://example.london</a> -> <a href="https://www.example.com/london" rel="nofollow noreferrer">https://www.example.com/london</a></p>
  
  <p><a href="http://example.london/anything" rel="nofollow noreferrer">http://example.london/anything</a> -> <a href="https://www.example.com/london" rel="nofollow noreferrer">https://www.example.com/london</a></p>
  
  <p>So ALL URLS must end up with 'www' added, .com domain only, https forced, php extension removed.</p>
  
  <p>I have tried literally hundreds of code snippets and combinations, but cant get all conditions to work at the same time.</p>