|Mod Rewrite from apache 1.3 to 2.2|
My 1and1 dedicated server was just upgraded from Apache 1.3 to 2.2 and most systems remain fine. But I know that some of the mod_rewrite rules have changed and as a result a few of my .htaccess rules no longer work.
I've been researching this to understand the difference but my experiements so far have come up with a blank, largely because most of this stuff goes over my head. Anyway it's easier to explain with an example.
RewriteRule ^2012/02/([^\.]+)$ http://www.example.com/index.php/2012/02/$1 [R=301,L]
I use that simple method to grab any URL calls to articles under my old links.. example (old link):
..and send them here (new link):
Yes I'm redirecting to a link with "index.php" added in because frankly playing with .htaccess pretty URL's has given me years of frustration :) . But since the move to Apache 2.2 this .htaccess method, which worked fine under 1.3, has stopped working.
Does anybody know what needs fixing to make it work again.
[edited by: engine at 8:05 am (utc) on Jun 19, 2012]
[edit reason] Please use example.com [/edit]
|My 1and1 dedicated server was just upgraded from Apache 1.3 to 2.2 |
<fe>Someone refresh my memory. What was the problem with 1and1 again?</fe>
By this time, you've naturally read the Forum Charter and the Sticky at the top of this thread, and are waiting for someone to come along and change your examples to example.co.uk ;)
When you say "has stopped working" do you mean that the Redirect doesn't take place at all, or that something else happens?
As written, the form
would not capture anything ending in .html, or in anything else, since you've explicitly said "capture only requests that contain neither a full stop nor a directory slash after the date". By your examples, that would seem to exclude, well, everything.
I can't remember as far back as 1.3. Did mod_rewrite back then ignore extensions? If you've got a closing anchor, you've got to give the whole URL all the way to the end. (Query strings don't count.)
Everyone is now waiting with bated breath to find out what that .php is doing in the middle, and why it has to be done with a Redirect. What do your current links look like?
As lucy says, your example rule doesn't match the example URL so no redirect could occur.
I would take this server upgrade as an opportunity to re-do the site using extenionless URLs, without any index.php part within them.
Have 1&1 still been hosting people on Apache 1.3 for all this time? That shows no regard for site security or of offering customers facilities that the rest of the world have had for years. I hope your hosting bill was in the range of the price of a few beers per year.
Lucy also says:
Oops. I read [^\.] backward. That isn't a directory slash, it's an escaped period. Things generally don't need to be escaped inside grouping brackets. There are exceptions, but the . isn't one of them. It would obviously be senseless to say "a group consisting of everything" --or, alternatively, "a group with no eligible members" ;)
Luckily it doesn't affect your present case.
The "/index.php/" is basically necessary to maintain consistantcy with an older CMS and to avoid mod_rewrite rules because I really have trouble wrapping my head around them :) . If I don't use it then thousands of article backlinks break and damage SEO. Works fine for my needs.. well it did.
Anyway.. moving on :) .
Yes Lucy I wouldn't be surprised if 1.3 ignored a lot of things but at the time it worked, so I cheated a bit to use that. Figured it would come back to bite me in the ass but then it's .htaccess so you expect that hehe.
Anyway it seems like you're saying that I can't redirect all/any calls to URL's like http://www.example.co.uk/2012/02/[anything matching here] to URL's like http://www.example.co.uk/index.php/2012/02/[anything matching here] with mod_rewrite?
You can, but not using the rule you quoted above.