• 0

htaccess Redirect / Rewrite questions


Question

Hi everyone!

 

I have a simple html site that I'm trying to make some changes to through the htaccess file.  This is a little outside of my comfort zone, so I wanted to ask on here what recommendations everyone has.

 

I obviously don't want to negatively impact the site's SEO...

 

The htaccess file already redirects from the non www to the https://www site.

 

I'm looking to change the file name of two pages, so I wanted to set up a 301 redirect from these old pages to the new.  However, this doesn't seem to work for some reason and I seem to be doing what every tutorial and discussion online suggests.

 

Next, I want to use the RewriteEngine to get rid of the html file extension.  While the code I have allows me to browse to the page without the html, it does not redirect the traffic from the old page to the new page.  I thought that it would?

 

Here's what I have now for the htaccess file.  Does anything look wrong to anyone?  Does anyone have any suggestions for doing this? 

 

#Permanent Redirects
Redirect 301 /24_7_page.html https://mysite.com/24-7-page.html
Redirect 301 /24_7_pagefaq.html https://mysite.com/24-7-pagefaq.html

 

#Redirect from WWW to non WWW
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.mysite.com [NC]
RewriteRule ^(.*)$ https://mysite.com$1 [L,R=301]

 

#Remove .html
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

 

I would also like to have the website not show https://mysite.com/index in the browser, but I haven't gotten to that yet.

 

Thanks!

Link to comment
https://www.neowin.net/forum/topic/1366964-htaccess-redirect-rewrite-questions/
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

This topic is now closed to further replies.