Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Need Help with Redirects

I'm trying to setup 301 redirects using a .htaccess file & it isn't working

3:43 pm on Nov 23, 2012 (gmt 0)

New User

joined:Nov 23, 2012
posts: 2
votes: 0


I've been trying to get some 301 redirects setup for the pages of a site that is moving Joomla install to a Wordpress site using the .htaccess. I'm having trouble getting the redirects to go to the new URLs without adding a file extension to the URL.

Here and example:

The original URL of the page is:

The new URL of the page is:

I set the following for the redirect:

Options +FollowSymLinks
RewriteEngine On
Redirect 301 /cms/index.php/Class-Newsletters.html http://www.example.com/site/for-class-of-2017/class-newsletters/ [R=301,L]

The problem is that the last slash is being removed and the .html is being added to the new URL:

This results in a page not found error.

I've tried adding a $ to the end of the URL in the redirect. This prevents the .html to the new URL, but adds a $ and still ends up with a page not found.

I'm at a loss of how to correct this. Any ideas?


8:18 pm on Nov 23, 2012 (gmt 0)


WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
votes: 10

welcome to WebmasterWorld, lesterj!

Redirect is a mod_alias directive and you probably want to use mod_rewrite directiives.
do you have any other redirects in your.htaccess?
8:21 pm on Nov 23, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
votes: 0


[R=301,L] is not valid syntax with the mod_alias Redirect directive.

Use mod_rewrite syntax: a RewriteRule with full protocol and hostname on the target URL and [R=301,L] flags.

It will give you exactly what you want.
9:26 pm on Nov 23, 2012 (gmt 0)

New User

joined:Nov 23, 2012
posts: 2
votes: 0


Phranque, I'm redirecting about 250 pages. The redirect I gave is just one example. I'm having the same issue with just about all of them.

G1smd, I'm not sure I follow. Could you provide an example?


2:10 am on Nov 24, 2012 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
votes: 287

You can't do what you need to do with mod_alias (Redirect by that name). So the first step is to convert any of your existing redirects from mod_alias format to mod_rewrite [httpd.apache.org] format. If you've got a text editor that does Regular Expressions it can be done almost automatically; I've posted the formulas a couple of times in this forum.


Eeeeuw! Is that really what the URLs look like? The form that's visible to the public? YUK. No wonder you're moving ;)

Moving from one CMS to another is double-tricky because you're juggling four things:

the old URL
the real location that those old URLs got rewritten to
the new URL
the real location that the new URLs get rewritten to

:: pause for heated argument about usefulness or otherwise of term "real location" in this context ::

You need to:

redirect from old URL to new URL
and then
rewrite from new URL to new location of content

Your WordPress install almost certainly came with a built-in htaccess that takes care of that last rewriting part. In fact I'm sure of it, because RewriteEngine On is a mod_rewrite directive. It has no effect on mod_alias. And, like all boilerplate htaccess files, the WordPress version is weighted down with lines that you can simply throw out. Notably all those <IfModule... envelopes. Just the envelope! Not its content.

But now you've got an extra step. You have to make sure your redirects are safely out of the way before the rewrites start, or else WordPress will be trying to rewrite Joomla URLs and there will be an unspeakable mess.

Do your two sets of URLs, old and new, have any identifying features so you can flag them instantly as one or the other? By "you" I mean "your htaccess". It needs to grab the right ones and skip the wrong ones, and the most efficient way is to do the identifying right in the Rule instead of having to evaluate Conditions every time.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members