Nested URLs and Rewrite rules in Apache2

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

Nested URLs and Rewrite rules in Apache2

Postby sradhakrishna » Tue Sep 15, 2009 6:33 pm

Hi,

I need some help with rewrite rules and nested URLs.

I am using TikiWiki for my website and am in the process of setting up SE friendly URLs for my projects. Specifically, I have the following rewrite rule for www.mywebsite.com/projects to point to a page that lists out all the projects hosted in mywebsite.

Code: Select all
RewriteRule ^Projects$  articles?type=Project  [L]


This works fine.

Now, I would like to point www.mywebsite/com/projects/project1 to point to a specific project. I have this rewrite rule

Code: Select all
RewriteRule ^(Projects/Project1)$     tiki-read_article.php?articleId=6


This works, but partially. The content is all rendered as text but the theme - images/ css etc all go for a toss - the page is completely in text.

I understand that this happens 'cause the relative paths in the theme/ css/ images all refer to Projects as the base folder instead of the root of the website.

I don't want to touch the CMS portion - change the theme/ css/ image paths in the files, more for reasons of upgradability.

Can someone help me understand and write a rule so that the above nested url works?

Regards, Radha
sradhakrishna
 
Posts: 1
Joined: Tue Sep 15, 2009 6:26 pm

Postby richardk » Wed Sep 16, 2009 2:34 pm

FAQ: Relative paths to images, JavaScript, CSS and other external/linked files are broken.

Better rules
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^Projects$          articles?type=Project             [QSA,L]
RewriteRule ^Projects/Project1$ tiki-read_article.php?articleId=6 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 19 guests

cron