express slash problem

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

express slash problem

Post by itsmani1 »

I want to redirect
/buy
or
/buy/

on buy.php

Here is my expression
RewriteRule ^buy/ /buy.php

it redirects /buy/ to buy.php but it does not redirect /buy to buy.php

any idea???

thanks in advance
User avatar
prometheuzz
Forum Regular
Posts: 779
Joined: Fri Apr 04, 2008 5:51 am

Re: express slash problem

Post by prometheuzz »

itsmani1 wrote:I want to redirect
/buy
or
/buy/

on buy.php

Here is my expression
RewriteRule ^buy/ /buy.php

it redirects /buy/ to buy.php but it does not redirect /buy to buy.php

any idea???

thanks in advance
Maybe make the '/' optional?

Code: Select all

RewriteRule ^buy/? /buy.php
(Untested, and I'm not familiar with Apache's Rewrite-Mod)
Post Reply