bulletck Posted October 28, 2008 Share Posted October 28, 2008 I need a regular expression to do the following: if someone goes to http://example.com/a the actual served page is http://example.com/a.php and also http://example.com/a/b/c/d to render http://example.com/a_b_c_d.php, etc. Quote Link to comment https://forums.phpfreaks.com/topic/130471-help-with-creating-a-particular-rewrite-rule/ Share on other sites More sharing options...
bulletck Posted November 5, 2008 Author Share Posted November 5, 2008 Any thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/130471-help-with-creating-a-particular-rewrite-rule/#findComment-683140 Share on other sites More sharing options...
corbin Posted November 5, 2008 Share Posted November 5, 2008 OMG I WILL HELP YOU I GUESS! I LOVE CAPS TOO! RewriteRule ^([a-z]+)/?$ /$1.php RewriteRule ^([a-z]+)/([a-z]+)/([a-z]+)/([a-z]+)/?$ /$1_$2_$3_$4.php Quote Link to comment https://forums.phpfreaks.com/topic/130471-help-with-creating-a-particular-rewrite-rule/#findComment-683241 Share on other sites More sharing options...
bulletck Posted November 7, 2008 Author Share Posted November 7, 2008 My file structure is as follows: webroot/css webroot/img webroot/js webroot/page1.php webroot/page1_sub.php So now using the rewrite rules I have http://webroot/page1/ render page1.php and http://webroot/page1/sub render page1_sub.php. All my paths to css, image and js files are relative. So page1 is fine but page1_sub is not. Is there a way I can keep all my php pages directly in the root and have all paths be relative with this new rewrite rule in place? Quote Link to comment https://forums.phpfreaks.com/topic/130471-help-with-creating-a-particular-rewrite-rule/#findComment-684221 Share on other sites More sharing options...
corbin Posted November 7, 2008 Share Posted November 7, 2008 Hrmmmm, it's not possible to have /folder/ treated like it's in the root. Well it might be possible through some obscure HTML tag or something, but no idea. You could just change all the links your self. Or, worst case, you could use preg_replace along with output buffering to rewrite links. Quote Link to comment https://forums.phpfreaks.com/topic/130471-help-with-creating-a-particular-rewrite-rule/#findComment-684326 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.