Answers.Body: <p>You can try this</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  
  
      RewriteEngine On
      RewriteCond %{HTTPS} off
      RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  
  
      # Send would-be 404 requests to Craft
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
  
      RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
  
      RewriteRule ^/outdoor-furniture/all-garden-benches /outdoor-furniture/garden-benches [NC,L,R=301]
  
      RewriteRule (.+) index.php?p=$1 [QSA,L]
  
  
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>If that doesn't work you can always try using a plugin for your redirects</p>
  
  <ul>
  <li><a href="https://plugins.craftcms.com/redirect" rel="nofollow noreferrer">https://plugins.craftcms.com/redirect</a></li>
  <li><a href="https://plugins.craftcms.com/retour" rel="nofollow noreferrer">https://plugins.craftcms.com/retour</a></li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-24T14:39:57.213Z
Answers.Text: Thanks, unfortunately that just gives me Page Not Found and also strips away all css. I'll check out the plugins...
Answers.UserDisplayName: cannon303
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-24T14:49:39.780Z
Answers.Text: The redirect plugin worked! Thank you. I don't suppose I'll ever get to the bottom of the problem with the .htaccess file as clearly something is wrong but the plugin does the trick!
Answers.UserDisplayName: cannon303
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-24T13:15:36.650Z
Answers.LastActivityDate: 2019-09-24T13:15:36.650Z
Answers.UserDisplayName: Steven Vandemoortele
Body: <p>Hi I'm having major problems trying to get my .htaccess file to rewriteRule or redirect one url to another. I've used .htaccess before on other cms installs and always work but for the life of me I cannot get it to work on my craft install.</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  
  
      RewriteEngine On
      RewriteCond %{HTTPS} off
      RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  
  
      # Send would-be 404 requests to Craft
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
  
      RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
  
      RewriteRule (.+) index.php?p=$1 [QSA,L]
  
      Redirect /outdoor-furniture/all-garden-benches https://www.mywebsite.co.uk/outdoor-furniture/garden-benches
  
  
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>This should redirect /outdoor-furniture/all-garden-benches to /outdoor-furniture/garden-benches (getting rid of the 'all-' bit).</p>
  
  <p>This actually redirects to this:</p>
  
  <p><a href="https://www.mywebsite.co.uk/outdoor-furniture/garden-benches?p=outdoor-furniture/all-garden-benches" rel="nofollow noreferrer">https://www.mywebsite.co.uk/outdoor-furniture/garden-benches?p=outdoor-furniture/all-garden-benches</a></p>
  
  <p>which is obviously wrong and still throws up a 404 error. I've tried everything now and what was supposed to be a 5 minute job is sending me round the bend so if anyone could shed some light on this then that would be great thanks!</p>
  
  <p><em>EDIT</em> The only thing that will help is if I take off ?p=$1 from this line:</p>
  
  <pre><code> RewriteRule (.+) index.php?p=$1 [QSA,L]
  </code></pre>
  
  <p>Once I do that the redirect works fine, however I'm reluctant to do that as it might break the site somewhere.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-09-24T21:08:26.500Z
Comments.Text: Have a look at this answer: https://craftcms.stackexchange.com/questions/14057/why-am-i-getting-p-oldpage-in-a-301-redirect
Comments.UserDisplayName: Seb
Tags: <redirect><htaccess><404>
Title: .htaccess file not rewriting url
ThreadText: # .htaccess file not rewriting url
  
  (Asked by: username_0 on 2019-09-24)
  
  Hi I'm having major problems trying to get my .htaccess file to rewriteRule or redirect one url to another. I've used .htaccess before on other cms installs and always work but for the life of me I cannot get it to work on my craft install.
  
  ```
  <IfModule mod_rewrite.c>
  
      RewriteEngine On
      RewriteCond %{HTTPS} off
      RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  
      # Send would-be 404 requests to Craft
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
  
      RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
  
      RewriteRule (.+) index.php?p=$1 [QSA,L]
  
      Redirect /outdoor-furniture/all-garden-benches https://www.mywebsite.co.uk/outdoor-furniture/garden-benches
  
  </IfModule>
  
  ```
  
  This should redirect /outdoor-furniture/all-garden-benches to /outdoor-furniture/garden-benches (getting rid of the 'all-' bit).
  
  This actually redirects to this:
  
  <https://www.mywebsite.co.uk/outdoor-furniture/garden-benches?p=outdoor-furniture/all-garden-benches>
  
  which is obviously wrong and still throws up a 404 error. I've tried everything now and what was supposed to be a 5 minute job is sending me round the bend so if anyone could shed some light on this then that would be great thanks!
  
  *EDIT* The only thing that will help is if I take off ?p=$1 from this line:
  
  ```
   RewriteRule (.+) index.php?p=$1 [QSA,L]
  
  ```
  
  Once I do that the redirect works fine, however I'm reluctant to do that as it might break the site somewhere.
  
  **Tags:** redirect, htaccess, 404
  
  > **Comments:**
  > **username_1**: Have a look at this answer: https://craftcms.stackexchange.com/questions/14057/why-am-i-getting-p-oldpage-in-a-301-redirect  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-09-24. Score: 1
  
  You can try this
  
  ```
  <IfModule mod_rewrite.c>
  
      RewriteEngine On
      RewriteCond %{HTTPS} off
      RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  
      # Send would-be 404 requests to Craft
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
  
      RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
  
      RewriteRule ^/outdoor-furniture/all-garden-benches /outdoor-furniture/garden-benches [NC,L,R=301]
  
      RewriteRule (.+) index.php?p=$1 [QSA,L]
  
  </IfModule>
  
  ```
  
  If that doesn't work you can always try using a plugin for your redirects
  
  * <https://plugins.craftcms.com/redirect>
  * <https://plugins.craftcms.com/retour>
  
  > **Comments:**
  > **username_0**: Thanks, unfortunately that just gives me Page Not Found and also strips away all css. I'll check out the plugins...  
  > **username_0**: The redirect plugin worked! Thank you. I don't suppose I'll ever get to the bottom of the problem with the .htaccess file as clearly something is wrong but the plugin does the trick!  
  
  ---
  
  