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
https://forums.phpfreaks.com/topic/71365-help-with-rewrite-rules/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.