Msg#: 4521900 posted 3:43 pm on Nov 23, 2012 (gmt 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: example.com/cms/index.php/Class-Newsletters.html
The new URL of the page is: example.com/site/for-class-of-2017/class-newsletters/
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: example.com/site/for-class-of-2017/class-newsletters.html
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.
Msg#: 4521900 posted 2:10 am on Nov 24, 2012 (gmt 0)
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.