Removing .html for index file in subfolder - html

I have just launched an English version of my website, adding an index.html file to an /en subfolder.
Now, I cannot access produktionskollektivet.com/en/ (it returns a 403 Forbidden), but have to link to produktionskollektivet.com/en/index.html.
I have a Rewrite rule in .htaccess that should remove the .html extension, but that doesn't seem to work in this instance.
Here is what I have in my .htaccess file:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
Redirect 301 /hej-hbg.html /index.html
Any help would be appreciated!

Removing .html extension using .htaccess file:
DirectoryIndex somepage.php home.php welcome.php index.html index.php landingpage.html
~Put there where you want to remove the extension.
Note: save the file with the .htaccess extension.
This is easy & works for me, Hope it helps.

Related

How to remove .html in url?

how to make this url(https://justinsimdev.com/about-us.html)become this url(https://justinsimdev.com/about-us)
basically just remove the .html from the link.
anyone can help me solved this problem.
I'm a self-taught web developer.
To remove the .html extension from your urls, you can use the following code in root/htaccess :
RewriteEngine on
RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]
NOTE: If you want to remove any other extension, for example to remove the .php extension, just replace the html everywhere with php in the code above.
Also see this How to remove .html and .php from URLs using htaccess`.
https://helponnet.com/2020/02/04/remove-html-and-php-extension-with-htaccess-rewriterule-url-rewriting-tips/

How to remove index.html from url

I have uploaded my HTML files to my website. Now i need to find a way to redirect users to a Home.html page when they enters www.mywebsite.com
i have tried to to this in htaccess but it did not work, i am not sure if it is correct
RewriteEngine On
#if request is mywebsite.co.uk/something OR
RewriteCond %{HTTP_HOST} ^mywebsite\.co.uk$ [OR]
# or www. mywebsite.co.uk/something
RewriteCond %{HTTP_HOST} ^www\.mywebsite\.co.uk$
# but not mywebsite.co.uk/Home.html
RewriteCond %{REQUEST_URI} !^/Home.html/
#change it to mywebsite.co.uk/Home.html/something
RewriteRule (.*) /Home.html/$1 [R=301]
Remove your code and put this only # .haccess file :
DirectoryIndex Home.html
Make sure the .htaccess file is in the directory where you want to change the index.html file

HTCaccess rediect repeating the subfolder

I am trying to redirect the main page to a blog. I am using the htcaccess code like this
Redirect / http://coolefitness.com/blog
The result is http://coolefitness.com/blogblogbloglblogblog
no idea why it is repeating the blog. I haven't told it to do that. I don't even know how I would make that loop happen.
Here is my full htcaccess
DirectoryIndex index.php
Redirect /index.html http://coolefitness.com/index.php
Redirect /members.html http://coolefitness.com/members.php
Redirect /what-is-coolefitness.html http://coolefitness.com/what-is-coolefitness.php
Redirect /instructors.html http://coolefitness.com/instructors.php
RewriteEngine On
#Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^([^/]+)/$ http://example.com/folder/$1 [R=301,L]
RewriteRule ^([^/]+)/$ http:/coolefitness.com/blog/$1 [R=301,L]
Redirect / http://coolefitness.com/blog
ErrorDocument 403 /404.php
ErrorDocument 404 /404.php
ErrorDocument 500 /404.php
FallbackResource payment/app.php
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
I have tried doing a rewrite, but that isn't working. I have removed it and the issue still happens.

Rerouting file to folder/directory name, but preserving directory children in Apache

I have a folder and a file with the same name, for example main.html and main/. I have the following rules in my .htaccess file:
RewriteEngine On
DirectorySlash off
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
These rules are made to remove all the .html extensions from the .html files when they are served to the browser.
How can I tell the browser to recognise that I want to view main.html without .html extension, not the main folder?
If this is not possible to do I am fine with having this main.html file in main folder, but when calling the main.html it should display the ../main/ instead of ../main/main.html. How would I do that?
If I specify the full path in the code like so: , browser will display the .html ending. But if I change it to browser says that there is nothing to load in the main/ and returns 403 Forbidden error.
Update:
RewriteCond %{REQUEST_FILENAME} main/$
RewriteRule ^(.*)/$ $1
Adding the rules above sort of works, but now I cannot access sub-directories in main directory because it gets redirected to main file.
Tried the following solutions without success:
https://stackoverflow.com/a/2017766/5153030
https://stackoverflow.com/a/1237547/5153030

How to get back to index.html in .htaccess?

I am completely new writing in .htaccess format. First what I did was add this in for the removal of my .html extensions. I am doing all this in cPanel under the /public_html/ folder. I also moved my .htaccess file inside that folder.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
All my pages that I have up right now are working without the extensions, expect when I go back to my homepage. Originally index.html but now when I click the home button my url looks like http://allisonshtml.com/public_html
Really to me when I think about this, its kind of backwards because my website is inside the public_html folder.
I tried everything in my power to fix this. Please help or any feedback would be lovely!
Figured it out, my Google chrome wasn't rendering. Cleared the background data and waaalaa it worked.