Is it possible to redirect traffic from page that doesn't exist to existing page with .htaccess?
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 detai开发者_运维知识库ls. Can someone point me to a good tutorial/reference file I can use to learn more about .htaccess commands in depth?
Thanks.
Try this mod_rewrite rule:
RewriteEngine on
RewriteCond $0 !=TeStPage
RewriteRule ^testpage$ /TeStPage [NC,R=301,L]
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>
精彩评论