Jump to content

Help with rewrite rules


jgd12345

Recommended Posts

Hi i'm trying to create a rewrite 2 rewrite rules one which goes to index.php and one that goes to info.php.

 

Here's some examples of urls which should go to index.php:

 

/news/ (with or without trailing slash)

/news/cat1/ (with or without trailing slash)

/news/cat1/sub1/ (with or without trailing slash)

/news/cat1/sub1/index.htm

 

Here's some examples of urls which should go to info.php:

 

/news/page.htm

/news/cat1/page.htm

/news/cat1/sub1/page.htm

 

So far i have:

 

RewriteRule ^news/?(.*?)?/?(index\.htm)?$ /news/index.php [NC,QSA,L]

RewriteRule ^news/(.*?)\.htm$ /news/info.php [NC,QSA,L]

 

But the first rule picks up any urls for the second rule aswell so /news/index.php is always shown.  If i change the first rule to (removing the ? after the last /):

 

RewriteRule ^news/?(.*?)?/(index\.htm)?$ /news/index.php [NC,QSA,L]

 

It works but means that i must specify a trailing slash which is not what i am after.  Really appreciate if someone could help.  Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.