• 0

htaccess Redirect / Rewrite questions



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.



Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By M_Lyons10
      Good morning everyone!
      Redirects and web.config changes still make me extremely nervous, so I always like to ask before I actually do anything.
      We recently upgraded to https and I set up a redirect from http to https.  The problem I am having is that it is redirecting multiple times.  From http://www to http://non-www and then again from http://non-www to https://non-www.
      How can I redirect once?  I've noticed a speed impact from doing it this way.
      So, I would like to redirect both http://www and http://non-www to https://non-www for the entire domain.
      I do have a couple of pages that have been redirected invidivually as well because the page has moved.
      I'm using Windows hosting.
      Here is my htaccess:
      #Redirect from WWW to non WWW
      RewriteEngine On
      RewriteCond %{HTTP_HOST} ^www.[mysite].com [NC]
      RewriteRule ^(.*)$ https://[mysite].com$1 [L,R=301]
      Thank you again for your help!
    • By slax
      I want to redirect my primary domain to https (http://www.website.com to https://www.website.com) and exclude all sub domains. (http://xyz.website.com to remain as http://xyz.website.com)
      I have been on google for too long and couldnt find the right solution, please help
      My .htaccess file
      RewriteEngine On
      RewriteCond %{HTTPS} off
      RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
    • By Goose3
      Hello Everyone! I'm new in programming better said I honestly don't have a clue but hopefully with time would like to gain
      a better insight to it's languages.
      At the moment I encountered a problem & don't have the slightest idea of what to do, it's extremely important and would deeply appreciate if anyone could help.
      Last year I built a personal website to put my work, everything worked great until a few months ago when through a weekly visitors report noticed a large amount of visitors coming from China & Mexico.
      I don't have anything against these two countries but through research & personal experience have learned that there are
      a few individuals who tend to take work from others & make lots of copies & then sell on the market. 
      Through google search discovered that there is a website that would generate the .htaccess file :
      would it work in blocking the countries selected? also where do I upload this .htaccess file on the server? ( read somewhere that it would need to be transfered on to the server with in ASCII mode??)  
      I would truly appreciate it if anyone could help with a simple step by step, just two days ago had to put a blank index.page on to the website to stop more visitors from viewing it, not including renaming the other files.
      Please I really do need your help.
    • By Hussam Al-tayeb
      Google is showing the actual wordpress sitemap.xml in search results which I don't want.
      The sitemap is generated by all in one seo plugin. it's a dynamically generated file.
      there is no real sitemap.xml file on the server.
      I want to noindex it.
      I tried those rules in htaccess but they don't work. this is probably due to the fact that the file isn't real.
      <FilesMatch "sitemap\.xml"> Header set X-Robots-Tag "noindex" </FilesMatch> <Files sitemap.xml> Header set X-Robots-Tag "noindex" </Files> <FilesMatch "\.xml$"> Header set X-Robots-Tag "noindex" </FilesMatch> Any other way to do it?
      *Edited for better wording*
    • By Copernic
      Can someone explain the difference betwen those two if there's any? Basically I want to display a different image when someone try to hotlink to a picture hosted in my website.

      Thank you.