Rewrite rules for Textpattern CMS

New to mod_rewrite? This is a good place to start.

Rewrite rules for Textpattern CMS

Postby speeke » Tue Nov 17, 2009 2:54 pm

I would like to add the following to an installation of the Textpattern (http://textpattern.com/) CMS:

Code: Select all
RewriteRule ^section/([0-9]+)/([0-9]+)/?$ section?month=$1-$2 [QSA,L]
RewriteRule ^search/([^/]+)/?$ search?q=$1 [QSA,L]


These both have .html file extensions.

I have tried adding:

Code: Select all
Options +FollowSymLinks -Multiviews


but am not having any luck. Can someone please suggest a fix?

The following comprises the default Txp .htaccess file:

Code: Select all
#DirectoryIndex index.php index.html

#Options +FollowSymLinks
#Options -Indexes

<IfModule mod_rewrite.c>
   RewriteEngine On
   #RewriteBase /relative/web/path/

   RewriteCond %{REQUEST_FILENAME} -f [OR]
   RewriteCond %{REQUEST_FILENAME} -d
   RewriteRule ^(.+) - [PT,L]

   RewriteCond %{REQUEST_URI} !=/favicon.ico
   RewriteRule ^(.*) index.php

   RewriteCond %{HTTP:Authorization}  !^$
   RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>

#php_value register_globals 0
speeke
 
Posts: 55
Joined: Tue Aug 08, 2006 6:18 pm

Postby speeke » Thu Nov 19, 2009 12:00 am

Never mind, all sorted.

However, I was wondering if there a more succinct way to express the following. It seems a bit verbose.

Code: Select all
RewriteRule ^([^/]+)/([0-9]+)/([0-9]+)/([0-9]+)/p([0-9]+)/?$ ?s=$1&month=$2-$3-$4&pg=$5 [QSA,L]
RewriteRule ^([^/]+)/([0-9]+)/([0-9]+)/p([0-9]+)/?$ ?s=$1&month=$2-$3&pg=$4 [QSA,L]
RewriteRule ^([^/]+)/([0-9]+)/p([0-9]+)/?$ ?s=$1&month=$2&pg=$3 [QSA,L]
RewriteRule ^([^/]+)/p([0-9]+)/?$ ?s=$1&pg=$2 [QSA,L]

RewriteRule ^([^/]+)/([0-9]+)/([0-9]+)/([0-9]+)/?$ ?s=$1&month=$2-$3-$4 [QSA,L]
RewriteRule ^([^/]+)/([0-9]+)/([0-9]+)/?$ ?s=$1&month=$2-$3 [QSA,L]
RewriteRule ^([^/]+)/([0-9]+)/?$ ?s=$1&month=$2 [QSA,L]


Many thanks.
speeke
 
Posts: 55
Joined: Tue Aug 08, 2006 6:18 pm


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 29 guests

cron