We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
Redirect 301 /index.html to / not working
-
- Posts: 7
- Joined: Wed Nov 22, 2017 8:43 am
Redirect 301 /index.html to / not working
Hi All,
I have Vesta installed with Nginx + Apache2.
I have this .htaccess set up:
if I put: www.domain.com, redirects perfectly to domain.com
the problem comes with the index.html, if I put domain.com/index.html or www.domain.com/index.html will not redirect to domain.com.
If I remove all this code, will not work any redirection even the first one: www.domain.com to domain.com.
thank you in advance.
I have Vesta installed with Nginx + Apache2.
I have this .htaccess set up:
Code: Select all
# Disable MutliViews
Options -Multiviews
ErrorDocument 404 /index.html
RewriteEngine on
# Remove www subdomain and redirect to HTTPS
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Remove "index.html" from all URLs
RewriteRule ^(|.+/)index\.html$ /$1 [R=301,L]
the problem comes with the index.html, if I put domain.com/index.html or www.domain.com/index.html will not redirect to domain.com.
If I remove all this code, will not work any redirection even the first one: www.domain.com to domain.com.
thank you in advance.
-
- Posts: 12
- Joined: Sat Jul 15, 2023 9:33 am
- Contact:
- Os: CentOS 7x
- Web: apache + nginx
Re: Redirect 301 /index.html to / not working
First of all, you can't use both Nginx + Apache2 web servers at the same time.
Nginx does not provide native htaccess support.
It looks like there might be a problem with how Apache is set up or how the.htaccess file is being read.
Re-setup the Apache configuration.
note: The.htaccess File Location should be in the root/public directory and is being read by Apache.
The Rewrite Module Should be enabled.
Now You can briefly change the.htaccess file to make it easier to find the problem. Try out the reroute with the following simple.htaccess file:
Save it and test if it works for you...
You can verify your URL on this tool, https://redirectchecker.com/ to get its detailed redirection path and its HTTP status code. give you some general idea of how your URL is being redirected.
note: above code is just for testing and giving a general idea; that's it.
Nginx does not provide native htaccess support.
It looks like there might be a problem with how Apache is set up or how the.htaccess file is being read.
Re-setup the Apache configuration.
Code: Select all
<Directory /path/to/your/YourSiteDirectory>
AllowOverride All
Require all granted
</Directory>
The Rewrite Module Should be enabled.
Code: Select all
sudo a2enmod rewrite
sudo systemctl restart apache2
Code: Select all
RewriteEngine On
Redirect 301 /index.html /
You can verify your URL on this tool, https://redirectchecker.com/ to get its detailed redirection path and its HTTP status code. give you some general idea of how your URL is being redirected.
note: above code is just for testing and giving a general idea; that's it.
-
- Posts: 7
- Joined: Wed Nov 22, 2017 8:43 am
Re: Redirect 301 /index.html to / not working
Thank you for your help.
I did everything as you said, but it seemed everything was already good in that way.
I tried later to use:
But no luck, when I enter to domain.com/index.html ... stays in domain.com/index.htm there is no redirection to domain.com
and when I enter to domain.com it gives Error
thanks again
I did everything as you said, but it seemed everything was already good in that way.
I tried later to use:
Code: Select all
RewriteEngine On
Redirect 301 /index.html /
and when I enter to domain.com it gives Error
thanks again
-
- Posts: 12
- Joined: Sat Jul 15, 2023 9:33 am
- Contact:
- Os: CentOS 7x
- Web: apache + nginx
Re: Redirect 301 /index.html to / not working
Let's try a different approach..
restart apache2
let me know if you have still issue
Code: Select all
Options -Multiviews
ErrorDocument 404 /index.html
RewriteEngine On
# Remove www subdomain and redirect to HTTPS
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# Redirect /index.html to root /
RewriteRule ^index\.html$ / [R=301,L]
# Redirect HTTP to HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
let me know if you have still issue
-
- Posts: 7
- Joined: Wed Nov 22, 2017 8:43 am
Re: Redirect 301 /index.html to / not working
thank you again.
I did the change on the .htaccess and restarted apache2 through the Vesta panel.
for: www.domain.com, does 301 to domain.com
with redirectchecker, does 301 and then 200.
when entering: domain.com/index.html only shows code 200, no redirection to domain.com, keeps the domain.com/index.html
thanks
I did the change on the .htaccess and restarted apache2 through the Vesta panel.
for: www.domain.com, does 301 to domain.com
with redirectchecker, does 301 and then 200.
when entering: domain.com/index.html only shows code 200, no redirection to domain.com, keeps the domain.com/index.html
thanks
-
- Posts: 12
- Joined: Sat Jul 15, 2023 9:33 am
- Contact:
- Os: CentOS 7x
- Web: apache + nginx
Re: Redirect 301 /index.html to / not working
Let's try a another method to see if it resolves the problem..
backup of your current .htaccess then try change it
please restart Apache again
Once done, Verify manually to see if redirection is working, and also check on redirect checker to make sure it's working properly as you expected.
backup of your current .htaccess then try change it
Code: Select all
Options -Multiviews
ErrorDocument 404 /index.html
RewriteEngine On
# Redirect /index.html to root /
RewriteRule ^index\.html$ / [R=301,L]
# Remove www subdomain and redirect to HTTPS
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# Redirect HTTP to HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Once done, Verify manually to see if redirection is working, and also check on redirect checker to make sure it's working properly as you expected.
-
- Posts: 7
- Joined: Wed Nov 22, 2017 8:43 am
Re: Redirect 301 /index.html to / not working
nehavilash wrote: ↑Wed Jul 26, 2023 9:18 pmLet's try a another method to see if it resolves the problem..
backup of your current .htaccess then try change it
please restart Apache againCode: Select all
Options -Multiviews ErrorDocument 404 /index.html RewriteEngine On # Redirect /index.html to root / RewriteRule ^index\.html$ / [R=301,L] # Remove www subdomain and redirect to HTTPS RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] # Redirect HTTP to HTTPS RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Once done, Verify manually to see if redirection is working, and also check on redirect checker to make sure it's working properly as you expected.
Thank you for your help.
I don't know, but still not working properly, when adding /index.html, no redirection is working... very strange.
thanks again
-
- Posts: 12
- Joined: Sat Jul 15, 2023 9:33 am
- Contact:
- Os: CentOS 7x
- Web: apache + nginx
Re: Redirect 301 /index.html to / not working
Instead of having multiple redirection rules, try setting a single rule for handling index.html
let me see what happen this time.
I hope it will work.
let me see what happen this time.
Code: Select all
RewriteEngine On
RewriteRule ^index\.html$ / [R=301,L]
# Redirect www subdomain to non-www and HTTP to HTTPS
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC,OR]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://yourdomain.com/$1 [R=301,L]
Re: Redirect 301 /index.html to / not working
It's worked when adding /index.html Many thanks!nehavilash wrote: ↑Wed Aug 09, 2023 1:06 pmInstead of having multiple redirection rules, try setting a single rule for handling index.html breakout game
let me see what happen this time.I hope it will work.Code: Select all
RewriteEngine On RewriteRule ^index\.html$ / [R=301,L] # Redirect www subdomain to non-www and HTTP to HTTPS RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC,OR] RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://yourdomain.com/$1 [R=301,L]
-
- Posts: 7
- Joined: Wed Nov 22, 2017 8:43 am
Re: Redirect 301 /index.html to / not working
Thank you, still having the problem, and now I have tested different option.nehavilash wrote: ↑Wed Aug 09, 2023 1:06 pmInstead of having multiple redirection rules, try setting a single rule for handling index.html
let me see what happen this time.I hope it will work.Code: Select all
RewriteEngine On RewriteRule ^index\.html$ / [R=301,L] # Redirect www subdomain to non-www and HTTP to HTTPS RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC,OR] RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://yourdomain.com/$1 [R=301,L]
I have changed the file extension of my index.html website to index.php, then on the .htaccess I've put this one:
Code: Select all
RewriteEngine On
RewriteRule ^index\.php$ / [R=301,L]
# Redirect www subdomain to non-www and HTTP to HTTPS
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC,OR]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://domain.com/$1 [R=301,L]
Now, If I put domain.com/index.php redirects to: domain.com
why with .php is working and not with .html?
many thanks!