For my site I have a RewriteRule that points the URL http://www.mysite.com/work to a work.php file. I also have a directory called “work” that has files in it, like project1.php, project2.php, etc…
What rules would I have to write so that the URL http://www.mysite.com/work knows to go to the work.php file, but the URL http://www.mysite.com/work/project1 knows I mean to go inside the directory “work” and display the project1.php file?
EDIT: Should point out, this is what I’m currently working with:
RewriteEngine On
RewriteBase /beta/
RewriteRule ^([a-z]+)$ $1.php [L]
Any additional tips to improve this security-wise? (Stopping directory jumping, etc…)
Try this:
That will ensure that
http://www.mysite.com/work(no trailing slash) will go to yourwork.phpfile.If you also want
http://www.mysite.com/work/(with trailing slash) to gowork.php, add this line just above the lastRewriteRule.That will redirect it to the URL with no trailing slash thus, displaying the
work.phpfile.UPDATE: Since you already have a
RewriteBasedirective, just put theRewriteRuleline(s) right after yourRewriteBasebut before yourRewriteRuleas the rule you’re using a catch-all and will match everything.