301 redirect

Why isn’t this working?

BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

END WordPress

Redirect 301 http://www.utahlibertylaw.com/about.html http://www.utahlibertylaw.com/about-us/

Why isn’t this working?

Dumb question … but it’s in a .htaccess file, right?

Because you need to put the Rewrite statement before the # BEGIN WordPress block. Otherwise the WordPress block will find that it can serve the URL and the Rewrite statement after that will be ignored; putting the Rewrite before the WordPress block solves that.

It is in the .htaccess file. Did you mean to say that I need the redirect before the wordpress block or have it like this?

Rémon,

First, I’ve got to assume that you’re referring to the Redirect statement, not the “Rewrite statement.”

Second, mod_alias is part of the Apache core so it makes no difference where it’s located (other than to help humans reading the code) because core directives are processed before non-core (mod_rewrite) directives. That’s simply not the problem.

Brian,

Obviously, you’re not looked at any of the WP threads in this board. :nono:

The problem you’re having with the about.html => about-us/ redirection is that you’re syntax is faulty. The syntax for the Redirect statement is

Redirect [status] URL-path URL

… where the [status] is optional (but should be included), the URL-PATH will not contain either the protocol (http://) or the {HTTP_HOST} (www.utahlibertylaw.com). The URL for the redirection must be absolute (/about-us/) or the complete (external absolute) URL (which you’ve done - albeit I’m not a fan of redirecting a file to a directory).

As for WP’s code:

  1. REMOVE the <IfModule> wrapper after testing. Not to do so is an abuse of the server (and should have you kicked off a shared server). It’s such an egregious error that I have a standard rant for it:

[rant #4][indent]The definition of an idiot is someone who repeatedly does the same thing expecting a different result. Asking Apache to confirm the existence of ANY module with an <IfModule> … </IfModule> wrapper is the same thing in the webmaster world. DON’T BE AN IDIOT! If you don’t know whether a module is enabled, run the test ONCE then REMOVE the wrapper as it is EXTREMELY wasteful of Apache’s resources (and should NEVER be allowed on a shared server).[/indent][/rant 4]

Nothing personal … but it’ll help you remember.

  1. RewriteBase is designed to UNDO a mod_alias redirection. Where’s the redirection? Do you really want to undo your about.html => about-us/? Remove this before it causes problems.

  2. I have no clue why WP added the RewriteRule ^index\.php$ - [L] statement as it’s already handled by the RewriteCond %{REQUEST_FILENAME} !-f so I remove this, too.

  3. Finally, the . in the RewriteRule is demanding at least a single character in the URI. If there is none (only the domain is requested), then this should fail. I prefer to add a ? after the dot character to make it optional. In addition, since this code is already located in the DocumentRoot, there is no need for the / before index.php in the redirection.

That’s quite a list but I hope it helps.

Regards,

DK