matstars Posted February 6, 2009 Share Posted February 6, 2009 good morning. I was wondering if it were possible to accomplish dynamic file names. Right now I am developing a site for schools and a typical link for a school would be /schools.php?sname=ps28 for PS28 would there be any way to make a folder schools and with htaccess or otherwise accomplish: /schools/ps28.php or /schools/ps28/ or /schools/ps28.htm and have it call a file that sets sname to ps28 without using GET? I hope that makes sense. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/144099-dynamic-file-names-with-php-or-otherwise/ Share on other sites More sharing options...
JonnoTheDev Posted February 6, 2009 Share Posted February 6, 2009 Mod Rewrite There is a forum on it within this website. Quote Link to comment https://forums.phpfreaks.com/topic/144099-dynamic-file-names-with-php-or-otherwise/#findComment-756092 Share on other sites More sharing options...
Loldongs Posted February 6, 2009 Share Posted February 6, 2009 put this in .htaccess RewriteEngine on RewriteRule ^schools/(.*)/ schools.php?sname=$1&%{QUERY_STRING} [PT] That should rewrite it like /schools/ps28/ Quote Link to comment https://forums.phpfreaks.com/topic/144099-dynamic-file-names-with-php-or-otherwise/#findComment-756107 Share on other sites More sharing options...
JonnoTheDev Posted February 6, 2009 Share Posted February 6, 2009 I personally would make it more robust that that as * will allow anything through Quote Link to comment https://forums.phpfreaks.com/topic/144099-dynamic-file-names-with-php-or-otherwise/#findComment-756116 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.