« "Family Fun" -- if you're the Manson family | Main | Another Spring, Another DEA Agent Shooting Himself in Foot Post »

A Plea For Tech Help

I'm not much of an Apache guru so I'm looking to the readership of Wizbang to help with a specialized modrewrite problem. I've got a directory called author of the root of all of the sites which contains two files - index.php and author.xml. Respectively they allow for author archives and author RSS feeds when passed the right variables.

What I'd like to do is show prettier URL's that the server will then translate into the proper parameterized call. If you're up for the challenge read on...

I'd like: http://wizbangblog.com/author/Kevin Aylward/ to actually load the following: http://wizbangblog.com/author/index.php?author=Kevin%20Aylward.

Also I'd like http://wizbangblog.com/author/Kevin Aylward/rss.xml to load the following: http://wizbangblog.com/author/author.xml?author=Kevin%20Aylward.

The only wrinkle is that I'd also like to use the solution on the subsites, which while they are addressed as third level domains (i.e. http://pop.wizbangblog.com/author/index.php?author=Kevin%20Aylward) are actually physically located in the directory structure under wizbangblog.com (ie. wizbangblog.com/pop/). I'm not sure that makes a difference, as each has their own .htaccess, but I wanted to give maximum detail.

Here is the current .htaccess. It's basically just the Movable Type generated stuff to do dynamic publishing.

## %%%%%%% Movable Type generated this part; don't remove this line! %%%%%%% # Disable fancy indexes, so mtview.php gets a chance... Options -Indexes +SymLinksIfOwnerMatch # The mod_rewrite solution is the preferred way to invoke # dynamic pages, because of its flexibility.

# Add mtview.php to the list of DirectoryIndex options, listing it last,
# so it is invoked only if the common choices aren't present...

DirectoryIndex index.php index.html index.htm default.htm default.html default.asp /mtview.php

RewriteEngine on

# don't serve mtview.php if the request is for a real directory
# (allows the DirectoryIndex lookup to function)
RewriteCond %{REQUEST_FILENAME} !-d

# don't serve mtview.php if the request is for a real file
# (allows the actual file to be served)
RewriteCond %{REQUEST_FILENAME} !-f
# anything else is handed to mtview.php for resolution
RewriteRule ^(.*)$ /mtview.php [L,QSA]

# if mod_rewrite is unavailable, we forward any missing page
# or unresolved directory index requests to mtview
# if mtview.php can resolve the request, it returns a 200
# result code which prevents any 4xx error code from going
# to the server's access logs. However, an error will be
# reported in the error log file. If this is your only choice,
# and you want to suppress these messages, adding a "LogLevel crit"
# directive within your VirtualHost or root configuration for
# Apache will turn them off.
ErrorDocument 404 /mtview.php
ErrorDocument 403 /mtview.php

## ******* Movable Type generated this part; don't remove this line! *******

One question is whether the code should go above the MT section or within it. I've been wholly unsuccessful at adding a proper RewriteRule to that structure and having it do anything short of generating 500 errors.

Any modrewrite gurus in the house who can get this to work? If so let fly with you're proposed solutions, and I'll test them out. The working solution will be credited to whoever comes up with in an article to submitted for publication on Six Apart's ProNet site.

Comments (8)

I'm no expert but I manage ... (Below threshold)

I'm no expert but I manage to get by with what I know (and alot of help from the net)...this code is conceptual and completely untested, but off the top of my head, the first way I would approach the problem would be something like this:

RewriteEngine on

RewriteCond %{REQUEST_URI} ^/author/(.*)/$
RewriteRule ^(.*)/author/(.*)/rss.xml$ %1/author/index.php?author=%2 [LR]

RewriteCond %{REQUEST_URI} ^/author/(.*)/rss.xml$
RewriteRule ^(.*)/author/(.*)/rss.xml$ %1/author/author.xml?author=%2 [LR]

It should work for both domain and sub-domain requests (once it is tested and made functional that is!)

Ok, {request_uri} might not... (Below threshold)

Ok, {request_uri} might not be the right variable or the Cond regexp may need some tweaking (I think request_uri may include the domain, but shouldn't include the transport {http://})

On the RequestCond lines, remove the '^' and it might work better.

I'll try it out and let you... (Below threshold)

I'll try it out and let you know... Thanks!

Everything I know about mod... (Below threshold)

Everything I know about mod_rewrite I got from the folks at pMachine. And maybe a website I found via Dogpile, but that didn't help much.

No luck. I even tried <a h... (Below threshold)

No luck. I even tried this, which looks like it should work.

I'm thinking that the DirectoryIndex line that adds mtview.php to the indexes screws me up. When I do get something that works I get the mtview.php file not found page.

Hmmm.This is proba... (Below threshold)


This is probably redundant:


Sorry but I don't know much about it, never really had a need so far, and I'm a little strapped for time right now.

RewriteRule ^/author/(.*)/?... (Below threshold)

RewriteRule ^/author/(.*)/? /author/index.php?author=%1 [QSA,L]

RewriteRule ^/author/(.*)/rss.xml$ /author/author.xml?author=%1 [QSA,L]

Try that - right below the "Rewrite Engine On"
(above the mtview stuff)

Try one at a time - one might work while another doesn't.

(I'm half asleep right now and I'm not used to working without a rewrite base, so no guarantees...)

Oh... and if it DOES work, ... (Below threshold)

Oh... and if it DOES work, I don't want my name at Six Apart.






Follow Wizbang

Follow Wizbang on FacebookFollow Wizbang on TwitterSubscribe to Wizbang feedWizbang Mobile


Send e-mail tips to us:


Fresh Links


Section Editor: Maggie Whitton

Editors: Jay Tea, Lorie Byrd, Kim Priestap, DJ Drummond, Michael Laprarie, Baron Von Ottomatic, Shawn Mallow, Rick, Dan Karipides, Michael Avitablile, Charlie Quidnunc, Steve Schippert

Emeritus: Paul, Mary Katherine Ham, Jim Addison, Alexander K. McClure, Cassy Fiano, Bill Jempty, John Stansbury, Rob Port

In Memorium: HughS

All original content copyright © 2003-2010 by Wizbang®, LLC. All rights reserved. Wizbang® is a registered service mark.

Powered by Movable Type Pro 4.361

Hosting by ServInt

Ratings on this site are powered by the Ajax Ratings Pro plugin for Movable Type.

Search on this site is powered by the FastSearch plugin for Movable Type.

Blogrolls on this site are powered by the MT-Blogroll.

Temporary site design is based on Cutline and Cutline for MT. Graphics by Apothegm Designs.

Author Login

Terms Of Service

DCMA Compliance Notice

Privacy Policy