CodeIgniter Forums
Accessing dynamic links in the format of domain.com/<dynamic_page_name> - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Accessing dynamic links in the format of domain.com/<dynamic_page_name> (/showthread.php?tid=63192)



Accessing dynamic links in the format of domain.com/<dynamic_page_name> - iconsh02 - 10-05-2015

I am using code Igniter for my PHP project. I want to give provision in my site such that users can create new pages of their own, and access them directly from www.domain.com/<their_page_name>.

But, my developers have raised a concern that, 1000's of dynamic links that are presented in the format of domain.com/<page_name> is "not good for site's performance". For some 10-15 pages, it is fine. But, beyond that, it would effect the site's performance.

So, they proposed that the URL format should be like www.domain.com/something/page_name (here, 'something' is the controller name)

But, I really can't sacrifice my framework nor my requirement. Is there any way that I can achieve the format of "www.domain.com/<page_name>" without effecting the site's performance?

Thanks a lot for the help


RE: Accessing dynamic links in the format of domain.com/<dynamic_page_name> - slax0r - 10-06-2015

What could possibly work is, to have a special subdomain for yhose user created pages, so your URLs would be user.domain.com/page_name and then use mod_rewrite to rewrite user.domain.com/page_name to www.domain.com/userpagecontroller/page_name

Then you don't need checks if that page_name is in fact a user created page, or some other page.


RE: Accessing dynamic links in the format of domain.com/<dynamic_page_name> - iconsh02 - 10-11-2015

Thnks a lot for the reply.

But, is it possible to altogether hide the controller name in the URL and access it directly from domain.com/page_name ?


RE: Accessing dynamic links in the format of domain.com/<dynamic_page_name> - slax0r - 10-12-2015

Well, you could make routes for every page name as well.
PHP Code:
$route["page_name1"] = "controller/page_name1";
$route["page_name2"] = "controller/page_name2";
// and so on... 

But, then each time you add/delete/update a page controller or method, you will have to update the routes. But would still be a better solution than my previous suggestion. I was probably drunk then.

Edit: of course if you have a lot of those pages stored in the database, and you want to have it dynamic, you can easily extend the router and make dynamic routes for those pages this way.


RE: Accessing dynamic links in the format of domain.com/<dynamic_page_name> - iconsh02 - 10-18-2015

hahaha...got it...thanks a lot man Smile Smile