views:

58

answers:

3

I'm currently working on an overhaul of my blog site, and have found a way to convert all my current pages into static html pages. They are currently using friendly url's which remap to a central index.php page with GET parameters attached on.

The change I am trying to make is have those same friendly URL's map to their html counterparts. I am currently using this rule:

RewriteRule ^archives?/([^/]+)/([^/.]+)/?$ archives/$1/$2.html

The error log is reporting that it cant find blah.html/ which means it's looking for the .html directory, instead of the .html file. So a better example:

/archives/2009/original-name

should be getting mapped to

/archives/2009/original-name.html

but is really getting mapped to

/archives/2009/original-name.html/

What am I missing here?

A: 

don't you need to use it the other way around? I didn't test the code but it should be something like this:

RewriteRule ^archives/(.*)/(.*).html archives/$1/$2
RJD22
No, he is mapping the friendly extensionless URLs to the HTML files, not the other way round.
Mark B
A: 

I can't see anything obviously wrong with your regex.

At a guess I'd say you might have a rule somewhere following this, which is redirecting anything without a trailing slash to its equivalent with the slash (a common thing to do to avoid duplicate content issues).

Mark B
I'd also go with this guess. Most frameworks already include Rewrite-rules that append slashes to URLs e.g. to deal with parameters so "URL/id/1/" would be rewritten to "URL/page.php?id=1". So whatever framework / software / product you're using may interfere with your Rewrite-rule.
Select0r
He is using Apache mod_rewrite.
Nick Berardi
A: 

You didn't escape your period in the 2nd statement. Try this.

RewriteRule ^archives?/([^/]+)/([^/\.]+)/?$ archives/$1/$2.html
Nick Berardi
Same thing, still looking for the directory instead of the file
Corey Hart
Then you might have to re-state your question. Nobody hear quite knows what you are talking about. Your above example was escaping control characters correctly. And you have some odd placement of "?" that you have quite explained. Like why is the "s" optional at the end of the "archives", is that intentional?
Nick Berardi