0

My .htaccess

Options -Indexes
DirectorySlash Off
RewriteEngine On
RewriteRule ^about$ about/about_me.html [L]

Is it possible to do this

Options -Indexes
DirectorySlash Off
RewriteEngine On
RewriteRule ^about$ about/about_me.html [L]

#Using multiple RewriteRules with diffrent names for same url
RewriteRule ^About$ about/about_me.html [L]
RewriteRule ^ABOUT$ about/about_me.html [L]
  • 1
    why you want to do this in the first place? URL's are not case sensitive. – tacoshy Sep 30 '21 at 21:19
  • @tacoshy "not case sensitive"? Then why is there a `NC` flag implemented in the rewriting module? – arkascha Sep 30 '21 at 21:23
  • Yes, this is possible. You did it, actually. The universe did not implode because of that ;-) – arkascha Sep 30 '21 at 21:25
  • 1
    @arkascha because you can make an url case sensitive if you want to use it for url shortener, base64 or enycrypting. But then only theat specific part will be case-sensitve. By default it is not. SO unless he didnt changed the normal case-insensitve behavior there would be no difference. – tacoshy Sep 30 '21 at 21:31
  • Okay, Thanks for the answers i totaly forgot that urls are case senstive, stupid me :):) – Yassin Rakha Sep 30 '21 at 22:14
  • @tacoshy of course URLs are case-sensitive. That several differently "cased" spellings might map to the same file/folder on disk, when the web server runs on a case-insensitive file system, is a different issue, and does not make URLs not case sensitive in themself. – CBroe Oct 01 '21 at 06:15
  • Sorry, but what you state about case insensivity is simply wrong. – arkascha Oct 03 '21 at 10:55

1 Answers1

1
RewriteRule ^about$ about/about_me.html [L]

#Using multiple RewriteRules with diffrent names for same url
RewriteRule ^About$ about/about_me.html [L]
RewriteRule ^ABOUT$ about/about_me.html [L]

Yes, you can do this, but... you shouldn't.

/about and /ABOUT are strictly speaking different URLs. (URLs are case-sensitive.) Google sees these as different URLs, so if /about and /ABOUT both serve the same content then you are potentially creating a duplicate content issue (whether that is actually going to be a problem or not is another matter).

Aside: You don't need multiple directives to do this, creating another directive for each variation. You can use the NC (nocase) flag on the RewriteRule directive to make it a case-insensitive match. For example:

RewriteRule ^about$ about/about_me.html [NC,L]

This will match about, ABOUT and AbOuT etc. and rewrite the request to about/about_me.html in all cases.

Case-insensitive and avoid duplicate content - Redirect instead

To allow all cased variations of about to be accessible and avoid the duplicate content issue you should externally redirect (not "rewrite") the non-canonical variations (eg. ABOUT and AbOuT etc.) to the canonical about. And only rewrite about to about/about_me.html.

For example, before the above "rewrite" you could implement the following "redirect" to canonicalize ABOUT and AbOuT to about.

# Redirect "ABOUT" and "AbOuT" to "about"
RewriteCond %{REQUEST_URI} ^/about$ [NC]
RewriteRule [A-Z] /about [R=301,L]

However, this rule is specific to one URL - it is not very practical if you have more than a handful of URLs. You might instead choose to simply lowercase all requested URLs. For example:

MrWhite
  • 43,179
  • 8
  • 60
  • 84