Jakehh Posted December 2, 2009 Share Posted December 2, 2009 Hello, I am currently hand-coding a website by myself, it requires the user to set a town and state, and with those i wish to do the following, state.site.com/town/, and i do not wish to consume space by making multiple folders. is there a quick and easy to maintain way? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/183692-subdomain-file-help-php-mysql-htaccess/ Share on other sites More sharing options...
rlelek Posted December 2, 2009 Share Posted December 2, 2009 Sounds like a job for.... *ModRewrite* http://www.workingwith.me.uk/articles/scripting/mod_rewrite Throw it in your .htaccess file Link to comment https://forums.phpfreaks.com/topic/183692-subdomain-file-help-php-mysql-htaccess/#findComment-969715 Share on other sites More sharing options...
Jakehh Posted December 3, 2009 Author Share Posted December 3, 2009 Im confused by .htaccess (Havent spent much time on it) i require it to do subdomain (WILDCARD) how do i do such thing? so for example, www.site.com/state/town.php would become state.site.com/town/ Link to comment https://forums.phpfreaks.com/topic/183692-subdomain-file-help-php-mysql-htaccess/#findComment-970417 Share on other sites More sharing options...
cags Posted December 3, 2009 Share Posted December 3, 2009 You'll need to be a little more specific with regards to "would become". What address do you wish the user to type into the Address bar? What is the address of the page you wish them to see? Do you wish the forward to show the 'actual' link in the Address bar, or the address they typed still? Link to comment https://forums.phpfreaks.com/topic/183692-subdomain-file-help-php-mysql-htaccess/#findComment-970419 Share on other sites More sharing options...
Jakehh Posted December 3, 2009 Author Share Posted December 3, 2009 Its hard to explain. The user logs in, they click a link that sends them to example. site.com/the_state_they_live_in/town.php, Then it would redirect them to the url, the_state_they_live_in.site.com/town/ If that makes sense. Link to comment https://forums.phpfreaks.com/topic/183692-subdomain-file-help-php-mysql-htaccess/#findComment-970422 Share on other sites More sharing options...
cags Posted December 3, 2009 Share Posted December 3, 2009 I don't see what's so hard to explain? All I asked was where the file is stored that you wish the user to see and where you want them to think they're are actually looking at (the link in the address bar). It makes a big difference to the pattern used. If you wish the address bar to contain http://domain.com/state/town but the user to actually view http://california.some-town.domain.com then the mod_rewrite could be something as simple as... RewriteRule ^([a-z]+)/([a-z]+)/?$ http://$1.$2.google.com But if you want the opposite (which it sounds like you do) then it's a bit more complicated and requires your DNS supporting it. This link seems a fairly comprehensive yet simplified resource. Link to comment https://forums.phpfreaks.com/topic/183692-subdomain-file-help-php-mysql-htaccess/#findComment-970427 Share on other sites More sharing options...
Jakehh Posted December 3, 2009 Author Share Posted December 3, 2009 It supports Wildcard DNS (I made sure of that when i got the domain) but i can not figure out Apache alone, could you possibly give me a snippet? If so thank you (Its hard to explain because its 12am and i cant think. ;3 Link to comment https://forums.phpfreaks.com/topic/183692-subdomain-file-help-php-mysql-htaccess/#findComment-970434 Share on other sites More sharing options...
cags Posted December 3, 2009 Share Posted December 3, 2009 The link I provided has nothing but snippets of code depending on what your trying todo will depend on which one you need. Link to comment https://forums.phpfreaks.com/topic/183692-subdomain-file-help-php-mysql-htaccess/#findComment-970435 Share on other sites More sharing options...
Jakehh Posted December 3, 2009 Author Share Posted December 3, 2009 thank you. Link to comment https://forums.phpfreaks.com/topic/183692-subdomain-file-help-php-mysql-htaccess/#findComment-970437 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.