Forum Moderators: phranque
I'm pretty new to URL rewriting and am quite stuck as to how to proceed. What I am trying to do is get my site to offer search engine friendly URLs for files and variables.
So if someone enters website/news/articles/newstory1
It redirects to website/news.php/articles/newstory1
Or if its just website/news or website/news/
It redirects to website/news.php
I can get it to do that with the following rules
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([a-z0-9_-]+)+/([a-z09_/-]+)?$ $1.php/$2 [NC,L]
RewriteRule ^([a-z0-9_-]+)+/?$ $1.php [NC,L]
However, only certain pages have their own php page, the rest will be accessing page.php and using the /#*$! to query a database, so in those case something like website/aboutus should redirect to website/page.php/aboutus . This is where I am having the problems. I have got a rule that will do this, but using it overwrites the 2 rules above, so everything is redirected to page.php . The rule is:
RewriteRule ^([a-z0-9_-]+)+.php$ page.php/$1 [NC]
Is there a way, maybe using conditions, that I could get it to perform the top 2 rules, and if they do not result in a file to then use the third rule? I have tried RewriteCond $1.php -f [NC] but I pretty lost as to how this is implemented.
Any help would be greatly appreciated, Thanks, Rob