tom at zepsu dot com
tom at zepsu dot com

Reputation: 307

double redirect

Hi I have a site that does an url rewrite to a page processing script hiding the url

#Direct to pageprocessor
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ pageprocessor.php?url=$1/

then urls are passed to the site as such http://domain.com/this/that page processor then tells the site what to display. hurrah!

my problem is that I need to add further rewrite to first go to page processor as it does but then add a / to the given url, as users will link to the site etc without the trailing /

it needs to do a 301 redirect to given url + / if one isn't present.

all my attempts has the redirect use the url that is passed to pageprocessor ie

http://domain.com/this/that becomes http://domain.com/this/pageprocessor.php?url=that/

hope this is clear enough is hard to explain :D cheers in advance

Upvotes: 1

Views: 522

Answers (1)

Nimit Dudani
Nimit Dudani

Reputation: 4860

I hope this may help

RewriteEngine On
RewriteBase /path/of/folder/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !example.php
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ /path/of/folder/$1/ [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /path/of/folder/index.php?url=$1

Upvotes: 3

Related Questions