Great work so far, Rickard. Bravo!
Rickard wrote:If I access e.g. /punbb/forum/21/ and the URL gets rewritten to /punbb/viewforum.php?id=21, the actual PHP script is executed just fine, but a problem appears for the CSS includes.
While I'm quite familiar with mod_rewrite from the admin side of things, I know very little about the actual code generation. I'll see if I can get some feedback from those who can provide it better than I.
In Wordpress, you append e.g. /feed/rss/ or /feed/atom/ to the end of an URL to access the feed. Is there any reason why that is preferable to just /rss/ or /atom/ ?
The rewrite rules that WordPress generates are very flexible and will look for any of the combinations you mentioned above. For example, tacking the following onto the end of WordPress URIs will output the following XML feed formats:
/feed/ -> RSS 2.0
/feed/rss/ -> RSS 0.92
/feed/rss2/ -> RSS 2.0
/feed/atom/ -> Atom
/rss/ -> RSS 0.92
/rss2/ -> RSS 2.0
/atom/ -> Atom
As for how PunBB presents the links, ideally this should be configurable, such that the admin interface presents two options: no directory preceding the feed format, or a custom-entered directory name (feed, feeds, newsfeeds, xml, etc).
For your reference, I'm including below some rewrite rules that were generated by WordPress 1.5. The way this works is that you specify what you want the URI structure to look like in the admin interface, and then WordPress generates the rewrite rules corresponding to the entered template. For the purposes of this illustration, I used /forums/ as the base URI and entered the following as the URI structure:
/post/%post_id%/
WordPress then generated the rewrite rules below. While this obviously doesn't apply directly (WordPress isn't for forums ), hopefully this will be of some use as a reference point. Let me know what you think.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /forums/
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [S=35]
RewriteRule ^feed/(feed|rdf|rss|rss2|atom)/?$ /forums/index.php?&feed=$1 [QSA,L]
RewriteRule ^(feed|rdf|rss|rss2|atom)/?$ /forums/index.php?&feed=$1 [QSA,L]
RewriteRule ^page/?([0-9]{1,})/?$ /forums/index.php?&paged=$1 [QSA,L]
RewriteRule ^comments/feed/(feed|rdf|rss|rss2|atom)/?$ /forums/index.php?&feed=$1&withcomments=1 [QSA,L]
RewriteRule ^comments/(feed|rdf|rss|rss2|atom)/?$ /forums/index.php?&feed=$1&withcomments=1 [QSA,L]
RewriteRule ^comments/page/?([0-9]{1,})/?$ /forums/index.php?&paged=$1 [QSA,L]
RewriteRule ^search/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$ /forums/index.php?s=$1&feed=$2 [QSA,L]
RewriteRule ^search/(.+)/(feed|rdf|rss|rss2|atom)/?$ /forums/index.php?s=$1&feed=$2 [QSA,L]
RewriteRule ^search/(.+)/page/?([0-9]{1,})/?$ /forums/index.php?s=$1&paged=$2 [QSA,L]
RewriteRule ^search/(.+)/?$ /forums/index.php?s=$1 [QSA,L]
RewriteRule ^post/category/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$ /forums/index.php?category_name=$1&feed=$2 [QSA,L]
RewriteRule ^post/category/(.+)/(feed|rdf|rss|rss2|atom)/?$ /forums/index.php?category_name=$1&feed=$2 [QSA,L]
RewriteRule ^post/category/(.+)/page/?([0-9]{1,})/?$ /forums/index.php?category_name=$1&paged=$2 [QSA,L]
RewriteRule ^post/category/(.+)/?$ /forums/index.php?category_name=$1 [QSA,L]
RewriteRule ^post/author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$ /forums/index.php?author_name=$1&feed=$2 [QSA,L]
RewriteRule ^post/author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ /forums/index.php?author_name=$1&feed=$2 [QSA,L]
RewriteRule ^post/author/([^/]+)/page/?([0-9]{1,})/?$ /forums/index.php?author_name=$1&paged=$2 [QSA,L]
RewriteRule ^post/author/([^/]+)/?$ /forums/index.php?author_name=$1 [QSA,L]
RewriteRule ^post/date/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$ /forums/index.php?year=$1&monthnum=$2&day=$3&feed=$4 [QSA,L]
RewriteRule ^post/date/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$ /forums/index.php?year=$1&monthnum=$2&day=$3&feed=$4 [QSA,L]
RewriteRule ^post/date/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$ /forums/index.php?year=$1&monthnum=$2&day=$3&paged=$4 [QSA,L]
RewriteRule ^post/date/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$ /forums/index.php?year=$1&monthnum=$2&day=$3 [QSA,L]
RewriteRule ^post/date/([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$ /forums/index.php?year=$1&monthnum=$2&feed=$3 [QSA,L]
RewriteRule ^post/date/([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$ /forums/index.php?year=$1&monthnum=$2&feed=$3 [QSA,L]
RewriteRule ^post/date/([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$ /forums/index.php?year=$1&monthnum=$2&paged=$3 [QSA,L]
RewriteRule ^post/date/([0-9]{4})/([0-9]{1,2})/?$ /forums/index.php?year=$1&monthnum=$2 [QSA,L]
RewriteRule ^post/date/([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$ /forums/index.php?year=$1&feed=$2 [QSA,L]
RewriteRule ^post/date/([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$ /forums/index.php?year=$1&feed=$2 [QSA,L]
RewriteRule ^post/date/([0-9]{4})/page/?([0-9]{1,})/?$ /forums/index.php?year=$1&paged=$2 [QSA,L]
RewriteRule ^post/date/([0-9]{4})/?$ /forums/index.php?year=$1 [QSA,L]
RewriteRule ^post/([0-9]+)/trackback/?$ /forums/index.php?p=$1&tb=1 [QSA,L]
RewriteRule ^post/([0-9]+)/feed/(feed|rdf|rss|rss2|atom)/?$ /forums/index.php?p=$1&feed=$2 [QSA,L]
RewriteRule ^post/([0-9]+)/(feed|rdf|rss|rss2|atom)/?$ /forums/index.php?p=$1&feed=$2 [QSA,L]
RewriteRule ^post/([0-9]+)/page/?([0-9]{1,})/?$ /forums/index.php?p=$1&paged=$2 [QSA,L]
RewriteRule ^post/([0-9]+)/?([0-9]+)?/?$ /forums/index.php?p=$1&page=$2 [QSA,L]
</IfModule>