Wordpress .htaccess redirects file extension and case-insensitive

admin

Administrator
Staff member
I am moving a website to wordpress but I want to keep the current URL structure for SEO purposes.

The current site uses a combination of .htm and .html files. I found success in redirecting to .htm when the request is .html.

For example

Code:
    RedirectMatch 301 (.*)\wp-site/mywebpage.html$ http://www.mydomain.com/wp-site/mywebpage.htm

I have trouble with the following:

when the .html file has upper and lower case. I can't seem to find a solution to redirect any request despite the case to its .htm equivalent

For example: My-Posts/Alpha-Page.html needs to redirect to my-posts/alpha-page.htm or MY-POSTS/ALPHA-PAge.html redirects to my-posts/alpha-page.htm (or any of "my-posts/alpha-page" that contains uppercase. basically all requests despite case needs to redirect to all lowercase .htm file)

I know it's a little difficult because it's a combination 1) I'm redirecting to .htm and 2) for the case insensitivity.

Few things to consider:

<ol>
<li>I know Wordpress posts are
case-insensitive. Wordpress's static
page are case-sensitive.</li>
<li>I know RedirectMatch won't work
because it matches it exactly.</li>
<li>I believe I need to use RewriteCond
and RewriteRule, but can't seem to
find "good" step by step
explanations. Also, I don't
understand their variables (ie:
%{HTTP_HOSTS}) and the regular
expression convention.</li>
<li>I am not an Apache/.htaccess or
regular expressions expert by any
means.</li>
</ol>

Theoretically, it seems there should be a way for it to work. I will continue to see if I can find solutions here at stackoverflow or other outside resources and if I do find a solution here at stackoverflow, I will marked this as solved and have it removed.

Any help is appreciated!

Thanks

UPDATE 06/17/2011:

Here is my current .htaccess file

Code:
    # BEGIN WordPress

    &lt;IfModule mod_rewrite.c&gt;


    RewriteEngine On


    RewriteBase /wp-test-2011-06-13/

    RewriteRule ^index\.php$ - [L]

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule . /wp-test-2011-06-13/index.php


    RedirectMatch 301 (.*)\wp-test-2011-06-13/redirect.html$ http://www.mydomain.com/wp-test-2011-06-13/redirect.htm


    RewriteRule ^ORLANDO-criminal-defense-attorney/defense-attorney-NEJAME.html$ /orlando-criminal-defense-attorney/defense-attorney-nejame.htm [QSA,NC,R=301]


    &lt;/IfModule&gt;


    # END WordPress

UPDATE 06/20/2011:

Here is my current .htaccess file:

Code:
    # BEGIN WordPress
    &lt;IfModule mod_rewrite.c&gt;

    Options +FollowSymlinks
    RewriteEngine On

    RewriteBase /wp-test-2011-06-13/
    RewriteRule ^/wp-test-2011-06-13/index\.php$ - [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* /wp-test-2011-06-13/index.php 

    RedirectMatch 301 (.*)\wp-test-2011-06-13/redirect.html$ http://www.mydomain.com/wp-test-2011-06-13/redirect.htm

    RewriteRule ^ORLANDO-criminal-defense-attorney/defense-attorney-NEJAME\.html$ /orlando-criminal-defense-attorney/defense-attorney-nejame.htm [QSA,NC,R=301]

    &lt;/IfModule&gt;

    # END WordPress

I get a Wordpress "Page Not Found" page when I type <a href="http://www.mydomain.com/wp-test-201...defense-attorney/defense-attorney-NEJAME.html" rel="nofollow">http://www.mydomain.com/wp-test-201...defense-attorney/defense-attorney-NEJAME.html</a> (or lowercase equivalent with .html)