views:

53

answers:

2

The issue I am trying to solve is that I have a folder with a name that has funny capitalizations, e.g. TeStPage. I would like all requests to my domain, in all versions of caps, redirect to that page.

I tried a simple:

Redirect /testpage http://www.mydomain.com/TeStPage

But that crashed my site, because it said 'Non-URL'.

How do I do .htaccess re-direct to handle all capitalization cases to be redirected to my /TeStPage url?

I searched Apache's documentation for the syntax and rules of .htaccess, but couldn't find a lot of details. Can someone point me to a good tutorial/reference file I can use to learn more about .htaccess commands in depth?

Thanks.

A: 

Try this mod_rewrite rule:

RewriteEngine on
RewriteCond $0 !=TeStPage
RewriteRule ^testpage$ /TeStPage [NC,R=301,L]
Gumbo
Thanks for this example Gumbo. I am going to try this a bit later, when I get back from class, and I will update you on how it turned out.
marcamillion
By the way Gumbo, should this work even if I am putting this .htaccess file in the httpdocs root dir, and not the dir that I want all requests redirected to?
marcamillion
Just tested it...it works!!! Thanks much Gumbo.
marcamillion
A: 

Did you check the mod_rewrite spec at http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html ?

Take for instance the typical Wordpress URL rewrite, which redirects all requests that point to a non existing file/folder to index.php, passing in the original request URL:

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase / 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule>
Remus Rusanu
Thanks for the link Remus. I did not check the mod_rewrite spec, because I wasn't aware I could do that. Now that I think about it, I realize that was a dumb oversight...but I neglected to do that.
marcamillion