• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Redirect http:// to https://and remove .html extensions [Branched]

New Here ,
Nov 30, 2019 Nov 30, 2019

Copy link to clipboard

Copied

Hi,

When I edit .htaccess file and put these codes into .htaccess file(To remove .html) its worked but only for index page.

Question 1).

How can I remove .html for all pages?

RewriteEngine on
RewriteCond %{REQUEST_URI} ^(.*/)index\.html$ [NC]
RewriteRule . %1 [R=301,NE,L]
# Begin Muse Generated redirects
# End Muse Generated redirects

 

When I added additional codes for Http to https got warning please see the attached

1_NgUzE1LSf0SywbJiCLasZg.jpeg

RewriteEngine On

RewriteCond %{HTTPS} off

RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_URI} ^(.*/)index\.html$ [NC]
RewriteRule . %1 [R=301,NE,L]
# Begin Muse Generated redirects
# End Muse Generated redirects

 

Question 2).

How can I fix both problems?

Thanks.

TOPICS
How to

Views

2.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 30, 2019 Nov 30, 2019

I have branched this to a new topic because your question is more complicated than the original thread from 2 years ago. 

 

Obviously this question has noting to do with Muse.  .htaccess is a server file.  Does your hosting plan include C-Panel?  If so, that's the easiest way to edit your .htaccess file.    See links below.

 

Removing file extensions.

https://www.plothost.com/kb/how-to-remove-php-html-extensions-with-htaccess/

 

Rewrite HTTP to HTTPS

https://www.name.com/support/articles/115005296088-Redirect-HTTP-to-HTTPS-automatically

...

Votes

Translate

Translate
Community Expert ,
Nov 30, 2019 Nov 30, 2019

Copy link to clipboard

Copied

I have branched this to a new topic because your question is more complicated than the original thread from 2 years ago. 

 

Obviously this question has noting to do with Muse.  .htaccess is a server file.  Does your hosting plan include C-Panel?  If so, that's the easiest way to edit your .htaccess file.    See links below.

 

Removing file extensions.

https://www.plothost.com/kb/how-to-remove-php-html-extensions-with-htaccess/

 

Rewrite HTTP to HTTPS

https://www.name.com/support/articles/115005296088-Redirect-HTTP-to-HTTPS-automatically

 

NOTE: do NOT  duplicate RewriteEngine On.   When it's on, it's on.

 

 

 

 

Nancy O'Shea— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 21, 2021 Aug 21, 2021

Copy link to clipboard

Copied

hi,

can you please send me that how to use both in one htaccess file

like one is http to https redirect

and second is hide .html file extension

please reply

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 21, 2021 Aug 21, 2021

Copy link to clipboard

Copied

This is NOT a Muse question.  It's a server configuration question.  Each hosting plan is different.  Some hosts support .htaccess and others don't.  Please contact your hosting provider for assistance.

 

 

 

Nancy O'Shea— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 21, 2021 Aug 21, 2021

Copy link to clipboard

Copied

thanks for quick response, yes my hosting is supporting .htaccess file and its already working fine for http to https redirection, but i want to add in that file for .html extension hide code

 

RewriteEngine On
RewriteCond %{HTTP_HOST} ^growtele\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.hostname.com/$1 [R,L]

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 22, 2021 Aug 22, 2021

Copy link to clipboard

Copied

See explanation below.

https://www.plothost.com/kb/how-to-remove-php-html-extensions-with-htaccess/

 

Nancy O'Shea— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 22, 2021 Aug 22, 2021

Copy link to clipboard

Copied

Dear Nancy
Thanks for your reply,
I understand what you send, but again my point is that I want to add two
module in one htaccess file
1. Redirection http to https
2. Hide .html extension

So please tell me to do that
Thanks in advance

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 22, 2021 Aug 22, 2021

Copy link to clipboard

Copied

Show us what you have currently. 

 

Nancy O'Shea— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 22, 2021 Aug 22, 2021

Copy link to clipboard

Copied

## Strip www from URLs ##
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^(.*)$ http://yourdomain.com/$1 [R=301,L]

 

## Strip .html from URLs ##
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]

 

## Rewrite http to https ##
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

 

## If needed, add extra conditions here... ##

 

Failing that, check your code's syntax below or contact your hosting provider.

http://www.htaccesscheck.com/

 

Nancy O'Shea— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 22, 2021 Aug 22, 2021

Copy link to clipboard

Copied

my code is below, but .html extension not hide, here my code

 

## Strip .html from URLs ##
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]


## Rewrite http to https ##
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
[L,R=301]

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

LATEST

Please contact your host.  It's possible your server is not configured to allow it.

 

 

 

Nancy O'Shea— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 01, 2019 Dec 01, 2019

Copy link to clipboard

Copied

Nancy Oshea,

Thanks for your quick response. Yes, I have access to cPanel and I replace those codes instead of my previous codes but not working. So I decided to keep my previous codes because something is better than nothing. My previous codes working for the index page.

Thanks, Kashem.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines