ConfusedLife123
ConfusedLife123

Reputation: 47

Make website case insensitive with .htaccess

This is what my .htaccess currently has

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

Options -Indexes

As it is right now, website.com/jobs works, while website.com/Jobs does not.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
CheckSpelling On
CheckCaseOnly On
Options -Indexes

I went ahead and made my .htaccess contain the following and my website now gives a 500 Internal Error.

Any ideas?

Upvotes: 2

Views: 168

Answers (2)

anubhava
anubhava

Reputation: 785276

I was just told by tech support that mod_speling is not enabled. The main problem is /Jobs to /jobs. is there anyway to do that without mod_speling?

You can do:

Options -Indexes
RewriteEngine on

# handle Jobs => jobs
RewriteRule ^Jobs/?$ /jobs [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

Upvotes: 1

thepiyush13
thepiyush13

Reputation: 1331

I think you need to use case-insensitive check in rewriteRule

Use of the [NC] flag causes the RewriteRule to be matched in a case-insensitive manner. That is, it doesn't care whether letters appear as upper-case or lower-case in the matched URI.

so maybe

RewriteRule ^[Ww](.*)$ $1.php   [NC] 

will work

Upvotes: 0

Related Questions