deepakonwww Posted September 14, 2007 Share Posted September 14, 2007 Hello PHP Friends, I need your help in a very crucial Issue. Basically I am developing my site in PHP. I want to use URL Rewriting in my site using mod_rewrite. I want my URL in this way http://www.mysite.com/development/php/basic/ this url should load the basic.php page from the php directory. here the important point is if user write something like http://www.mysite.com/development/php/basic the slash ("/") should be added automatically to the URL. and if user writes http://www.mysite.com/development/php then a slash should be added to the URL and it will load the default.php page from that directory. here you can assume that every directory contains the default page. and if user writes http://www.mysite.com/my then it should add the slash to the URL like this http://www.mysite.com/my/ and load the my.php page. Hope I have made myself clear. Please guide me in this regards. Thanks in Advance.... Quote Link to comment https://forums.phpfreaks.com/topic/69288-help-needed-in-url-rewriting-issue/ Share on other sites More sharing options...
hackerkts Posted September 14, 2007 Share Posted September 14, 2007 Try to use optional, replace / with /? in your rewrite rule. Quote Link to comment https://forums.phpfreaks.com/topic/69288-help-needed-in-url-rewriting-issue/#findComment-348178 Share on other sites More sharing options...
deepakonwww Posted September 14, 2007 Author Share Posted September 14, 2007 Hi, First of all thanks for your reply.. But I am totally new to the URL Rewriting. So what I need is a Rewriting Rule. Please help Quote Link to comment https://forums.phpfreaks.com/topic/69288-help-needed-in-url-rewriting-issue/#findComment-348188 Share on other sites More sharing options...
hackerkts Posted September 14, 2007 Share Posted September 14, 2007 Oh I thought you had already got it working. RewriteEngine on RewriteRule ^development/([a-z)]/?([a-z])?/?$ /$1/$2.php RewriteRule ^([a-z])/?$ $1.php Not sure if it works, but you will need to do your part on PHP regarding the default.php Quote Link to comment https://forums.phpfreaks.com/topic/69288-help-needed-in-url-rewriting-issue/#findComment-348254 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.