Capital letters URL with cPanel? - html

my website have this link, but when I change hello to HELLO, page is not found
www.mywebsite.com/hello
I've searched a lot of question about capital letters URL. The answer is basically the same, which is setting the .htaccess and setting the RewriteMap httpd.conf. My website is using cPanel 62.0.15 and I don't think that I can access httpd.conf. I didn't found that file anywhere.
Is there any other way to get capital letters URL working? Or where can I find the httpd.conf file in cPanel?
My .htaccess
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteBase /
RewriteRule ^(.*)$ index.php?xparam=$1 [QSA,L]
</IfModule>

If you add NC as a RewriteRule then this makes the match case insensitive:
RewriteRule ^(.*)$ index.php?xparam=$1 [QSA,L]
Becomes ..
RewriteRule ^(.*)$ index.php?xparam=$1 [QSA,L,NC]
See https://httpd.apache.org/docs/current/rewrite/flags.html for more

Related

Folder name clashing with html page (using htaccess)

I have a static html website and I'm using .htaccess to clean up the url by removing the .html from the address.
The issue is when I visit "example.com/path" it clashes with the folder "path" but when I choose to manually enter example.com/path.html I will get the page loading just fine.
The URLs inside the "path" folder are working fine as well with "example.com/path/page1" both with and without .html file extension.
My only alternative just now is to change the folder name from the file name as subtle as possible until I find a solution.
I've had a look at related questions being asked as well as a bit of research on conditions to put into my .htaccess file but having no luck.
Appreciate any help.
EDIT ***
htaccess file ..
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.co.uk/$1 [R,L]
RewriteCond %{HTTP_HOST} !^www.example.co.uk$ [NC]
RewriteRule ^(.*)$ https://www.example.co.uk$1 [L,R=301]
Just returning a 403.
Kindly try below code
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^ %1 [R,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*?)/?$ $1.html [L]
Note : Don't forget to replace RewriteBase. As of now i have added / bca my project is in root folder. You can simply add folder name like below
RewriteBase /yourfoldername/
Hope it will work for you.

Removing html file extensions from website urls

Im editing my .htaccess file in the root folder of my website server to get rid of all the .html extensions in the URL's (4 in total) and I save it and its not working. Obviously something I'm doing wrong...
This is what i have in .htaccess:
# Begin Muse Generated redirects
# End Muse Generated redirects
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
Use this if you must use .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

getting html5 boilerplate .htaccess file to work on dreamhost site

Completely new to Apache.
Trying to remove ".html" extension from urls by adding the following lines (found here):
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
to this (including ^ those lines now):
<IfModule mod_rewrite.c>
RewriteEngine On
# Enable the `FollowSymLinks` option if it isn't already.
# Options +FollowSymlinks
# If your web host doesn't allow the `FollowSymlinks` option, you need to comment it out or remove it, and then uncomment the `Options +SymLinksIfOwnerMatch` line, but be aware of the performance impact.
# Options +SymLinksIfOwnerMatch
RewriteBase /
# RewriteOptions <options>
RewriteCond %{HTTPS} =on
RewriteRule ^ - [env=proto:https]
RewriteCond %{HTTPS} !=on
RewriteRule ^ - [env=proto:http]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
</IfModule>
But the .html extensions remain in the visible urls.
I couldn't find any info on whether Dreamhost allows FollowSymLinks, but I tried it enabled, as well as SymLinksIfOwnerMatch, I also tried disabling RewriteBase / and even removing the mod rewrite if statement. I'm placing the file in my website's root directory, and tried placing it in the parent folder to that too with no results. Anybody have an idea what I'm doing wrong?
The full .htaccess is here.
Solved:
I still don't know why the above code didn't work, but I just used the code from Dreamhost's wiki instead:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\ HTTP/
RewriteRule ^(.*)index$ http://Your_Site_Url_Goes_Here.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://Your_Site_Url_Goes_Here.com/$1 [L,R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.+)\.html\ HTTP/
RewriteRule ^(.+)\.html$ http://Your_Site_Url_Goes_Here.com/$1 [L,R=301]
RewriteRule ^([a-z]+)$ /$1.html [L]
</IfModule>
Be mindful that the above code may cause new problems, as it is causing one of my pages to return a 403 Forbidden error, but I think that's a whole other problem irrelevant to my original question so I consider this a solve and will fix the above code when I find a solution elsewhere.
Symlinks seem to have been irrelevant.
.htaccess file goes in >mySite.com directory, rather than the directory that contains this directory
DreamHost wiki has a guide on how to use Apache redirects and rewrites. The guide mentions FollowSimylinks
You should also check the Apache error logs to see what fails (and edit your question to be more specific about the result you see in the browser).

Htaccess removing .html

This is code from my .htaccess file
AddDefaultCharset UTF-8
Options -Indexes
# blocks direct access to the XML files - they hold all the data!
<Files ~ "\.xml$">
Order allow,deny
Deny from all
Satisfy All
</Files>
<Files sitemap.xml>
Order allow,deny
Allow from all
Satisfy All
</Files>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.mywebsite.co.uk$ [NC]
RewriteRule ^(.*)$ http://mywebsite.co.uk/$1 [R=301,L]
# Usually it RewriteBase is just '/', but
# replace it with your subdirectory path
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /?([A-Za-z0-9_-]+).html$ index.php?id=$1 [QSA,L]
Most of it was previously generated not by me, and that's may be the problem i cannot understand it. I wanted to remove .html from mywebsite.co.uk/promotions.html.
I have tried adding, deleting lines and searched for answers for a long time and i still get nothing. Everything i get is sth like: mywebsite.co.uk/?id=promotions which is even worse. Actually i am newbie with htaccess and most of this code is more or less magic for me. I would be happy to get some help.
You need to do it like this
RewriteCond /%{REQUEST_FILENAME}.html -f
RewriteRule ^([a-zA-Z0-9_-\s]+)/$ /$1.html

mod_rewrite - neewd to make an exception for addresses that contain a certain word

HI, I have a mod_rewrite in my .htaccess file that is reformatting address. I already have one exception that will keep .cfg files free from the rewrite, I'm trying to do that same with .html files that contain the word "client" but have had no luck trying a number of different approaches. I'm out of my depths with .htaccess stuff unfortunately.
Here is the file currently:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule \.cfg$ - [L]
RewriteRule client - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php
</IfModule>
Any help would be greatly appreciated!
Change the client line to:
RewriteRule client(.*?)\.html - [L,NC]