le007 Posted September 14, 2007 Share Posted September 14, 2007 Say a direct link is: www.mywebsite.com/index.php?locate=register where in my functions.php if locate=register include regsiter.php anyone know how to just have it as: www.mywebsite.com/register? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/69348-re-route/ Share on other sites More sharing options...
Jessica Posted September 14, 2007 Share Posted September 14, 2007 Use mod_rewrite in htaccess. Quote Link to comment https://forums.phpfreaks.com/topic/69348-re-route/#findComment-348435 Share on other sites More sharing options...
le007 Posted September 14, 2007 Author Share Posted September 14, 2007 hey jesirose, thanks for the reply - I've VERY new to php, don't get you - any examples? Quote Link to comment https://forums.phpfreaks.com/topic/69348-re-route/#findComment-348439 Share on other sites More sharing options...
Jessica Posted September 14, 2007 Share Posted September 14, 2007 It's not just PHP. If you google it you'll find lots of tutorials on using mod_rewrite with php. Quote Link to comment https://forums.phpfreaks.com/topic/69348-re-route/#findComment-348440 Share on other sites More sharing options...
le007 Posted September 14, 2007 Author Share Posted September 14, 2007 Hey, thanks. I've googled it - looks pretty tricky tho ??? I only need the 1 address re-routed which is awkward but still needed Quote Link to comment https://forums.phpfreaks.com/topic/69348-re-route/#findComment-348443 Share on other sites More sharing options...
phat_hip_prog Posted September 14, 2007 Share Posted September 14, 2007 There's another forum which some kind soul will help you with it! http://forum.modrewrite.com/ Quote Link to comment https://forums.phpfreaks.com/topic/69348-re-route/#findComment-348446 Share on other sites More sharing options...
Jessica Posted September 14, 2007 Share Posted September 14, 2007 If you're only ever going to do that one address, why don't you just make the contents of : index.php?locate=register on an index page in a register folder? Quote Link to comment https://forums.phpfreaks.com/topic/69348-re-route/#findComment-348448 Share on other sites More sharing options...
le007 Posted September 14, 2007 Author Share Posted September 14, 2007 Thats a good idea, however; my entire website is a 3 column layout with the middle changing through locate. The rest remains static PLUS I've just realised I'll need 33 in total changes! I read an article and came up with this: RewriteEngine On RewriteRule ^register$ index.php?locate=register Not sure where or what to save the .htaccess file as Quote Link to comment https://forums.phpfreaks.com/topic/69348-re-route/#findComment-348452 Share on other sites More sharing options...
phat_hip_prog Posted September 14, 2007 Share Posted September 14, 2007 This will work in your root directory, directing everything to index.php, adding the request to the 'local'. e.g. if you called 'www.mywebsite.com/register' it would really call 'www.mywebsite.com/index.php?local=register': RewriteEngine on Options +FollowSymlinks RewriteBase / RewriteRule ^([^/]+)/?$ index.php?local=$1 [QSA,L] # files in home dir only Quote Link to comment https://forums.phpfreaks.com/topic/69348-re-route/#findComment-348455 Share on other sites More sharing options...
phat_hip_prog Posted September 14, 2007 Share Posted September 14, 2007 You can have a .htaccess file in each directory. Basically it's a per directory directives for your server. Make sure your server has this functionality turned on. The dot (.) in front of the file means it hidden (on unix), just save it as a text file (no extension, just named as '.htaccess') Quote Link to comment https://forums.phpfreaks.com/topic/69348-re-route/#findComment-348459 Share on other sites More sharing options...
le007 Posted September 14, 2007 Author Share Posted September 14, 2007 Hey phat_hip_prog, thanks for your help buddy. I tried this: RewriteEngine On RewriteRule ^register$ index.php?locate=register Saved this as .htaccess in the same directory as index.php and it worked. I don't really get your code: RewriteEngine on Options +FollowSymlinks RewriteBase / RewriteRule ^([^/]+)/?$ index.php?local=$1 [QSA,L] # files in home dir only although I see what you're saying about saving in each directory. Quote Link to comment https://forums.phpfreaks.com/topic/69348-re-route/#findComment-348466 Share on other sites More sharing options...
phat_hip_prog Posted September 14, 2007 Share Posted September 14, 2007 You 'can' have one in every/any directory, there's lot's more you can do with them like password protect, custom error pages, etc... You'll get some info here, .htaccess files use same directives as the apache conf file: http://httpd.apache.org/docs/2.2/howto/htaccess.html http://httpd.apache.org/docs/2.2/configuring.html Quote Link to comment https://forums.phpfreaks.com/topic/69348-re-route/#findComment-348470 Share on other sites More sharing options...
le007 Posted September 14, 2007 Author Share Posted September 14, 2007 Ok I'll have a look - thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/69348-re-route/#findComment-348474 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.