MsKazza Posted June 2, 2020 Share Posted June 2, 2020 Hi Not even sure if this is possible, but well here goes: We have a wholesale site where companies, organisations, clubs etc can buy products. We are setting it up so that these organisations can pick their items then our system will set up a webshop for them, they can then send the link to their employees, members to order the items that the company has chosen ahead of time. our site would be http://www.ourcompanyname.com/productpage.php?companyName=ourClient we would like if poss : http://www.ourcompanyname.com/ClientOrganisationName(either with or without the PHP extension). ClientOrganisationName would be taken from their record in mysql. If this is possible could someone please just tell me what i need to look up. I think wordpress has something similar which is prob where i thought about using on our site. thanks very much, MsKazza. Quote Link to comment https://forums.phpfreaks.com/topic/310884-name-a-php-page-after-a-field-in-mysql-possible/ Share on other sites More sharing options...
requinix Posted June 2, 2020 Share Posted June 2, 2020 You can definitely do /ClientOrganizationName being treated as /productpage.php?companyName=ClientOrganizationName. Note the two names are the same. The concept is called URL rewriting and there's a lot of information on the internet about it. What you do is tell your web server that requests for a URL in a certain pattern should be "rewritten" to another URL. In your case, you would tell it that a URL that is a name without any "directory" (so /Client matches but not /foo/Client or /Client/foo) takes that name and gives it to productpage.php. If you're using WordPress, IIRC it has a URL rewriting feature by itself (the web server was told that everything should go through WP, and then WP itself decides what to do) so you would tell WP that pages in that pattern should be treated a certain way. There is one restriction, though: this URL pattern needs to be dedicated to this one particular feature. Otherwise the URLs would be ambiguous. Quote Link to comment https://forums.phpfreaks.com/topic/310884-name-a-php-page-after-a-field-in-mysql-possible/#findComment-1578609 Share on other sites More sharing options...
MsKazza Posted June 2, 2020 Author Share Posted June 2, 2020 thanks very much for that, i'll look into it now. Am only going to be using it for the one page, and not using wordpress just that where i thought i'd seen something like it. thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/310884-name-a-php-page-after-a-field-in-mysql-possible/#findComment-1578610 Share on other sites More sharing options...
requinix Posted June 2, 2020 Share Posted June 2, 2020 I feel like I need to emphasize the last thing I wrote a little bit more. By using URLs like /ClientOrganizationName, where you have only one "segment" of the path, you are limiting what you can do in the future. Anything else that's one segment will look like a company name. That means you can't do stuff like /about or /Contact-Us because those will look like companies. You should namespace the URL so that you can safely dedicate the entire pattern to companies without worrying about it conflicting with anything else. Doesn't have to be complicated. I'm thinking like /shop/ClientOrganizationName: you're able to add a new keyword in there and it's still easy for anyone to understand. Quote Link to comment https://forums.phpfreaks.com/topic/310884-name-a-php-page-after-a-field-in-mysql-possible/#findComment-1578611 Share on other sites More sharing options...
MsKazza Posted June 4, 2020 Author Share Posted June 4, 2020 thanks for your reply, i'll keep that in mind while implementing it, for now only intend on using it on one page, but i guess future proofing site couldn't hurt. Quote Link to comment https://forums.phpfreaks.com/topic/310884-name-a-php-page-after-a-field-in-mysql-possible/#findComment-1578640 Share on other sites More sharing options...
gizmola Posted June 5, 2020 Share Posted June 5, 2020 2 hours ago, MsKazza said: thanks for your reply, i'll keep that in mind while implementing it, for now only intend on using it on one page, but i guess future proofing site couldn't hurt. It's really important to have a scheme like the one requinix is suggesting. Let's consider it this way (without the rewriting) #home page. You can make this the default page by routing to home if there is no route parameter index.php?route=home #rewrite route /home #contact page index.php?route=contact #rewrite route /contact #faq index.php?route=faq #rewrite route /faq #faq item #3 index.php?route=faq&item=3 #rewrite route /faq/3 #acme customer store page list of items index.php?route=shop&customer=acme #rewrite route /shop/acme #individual item #14 page in acme store index.php?route=shop&customer=acme&item=14 #rewrite route /shop/acme/14 Quote Link to comment https://forums.phpfreaks.com/topic/310884-name-a-php-page-after-a-field-in-mysql-possible/#findComment-1578645 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.