homepage Welcome to WebmasterWorld Guest from 54.197.171.109
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Mod Rewrite from apache 1.3 to 2.2
ispreview




msg:4466677
 11:37 am on Jun 18, 2012 (gmt 0)

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):

http://www.example.com/2012/02/uk-broadband-first-to-launch-commercial-4g-mobile-internet-service-via-3-5ghz.html

..and send them here (new link):

http://www.example.com/index.php/2012/02/uk-broadband-first-to-launch-commercial-4g-mobile-internet-service-via-3-5ghz.html

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]

 

lucy24




msg:4466766
 4:20 pm on Jun 18, 2012 (gmt 0)

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

^2012/02/([^\.]+)$

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?

g1smd




msg:4466801
 5:41 pm on Jun 18, 2012 (gmt 0)

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.

lucy24




msg:4466914
 9:50 pm on Jun 18, 2012 (gmt 0)

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.

ispreview




msg:4467132
 8:27 am on Jun 19, 2012 (gmt 0)

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?

g1smd




msg:4467332
 7:33 pm on Jun 19, 2012 (gmt 0)

You can, but not using the rule you quoted above.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved