url routing to dynamic file name |
[eluser]RaZoR LeGaCy[/eluser]
I need Code: http://www.hellhorror.com/demon-names-16.html Code: http://www.hellhorror.com/demons/demonology/16/DYNAMIC-NAME.html How may I do it?? In routing, a seperate file that checks the segment then checks the DB and inserts the file-name? Best optimized solution please.
[eluser]Code Arachn!d[/eluser]
Do you have a lot of these names? Would it make sense to just use a simple .htaccess 301 redirect?
[eluser]RaZoR LeGaCy[/eluser]
I have hundreds in different sections so this is much needed
[eluser]Nillian[/eluser]
Be warned, I'm a noob, so take this advice with a pinch of salt :cheese: Could you use an apache Rewrite Map? You could have a PHP script to write a new map file when new pages are added/needed. Otherwise I guess you could always route to a script that figures out where to redirect the user to (using the URI class and your DB tables) and send a Redirect().
[eluser]RaZoR LeGaCy[/eluser]
lets try again in the forums Still wondered how to do this
[eluser]John_Betong[/eluser]
[quote author="RaZoR LeGaCy" date="1187864348"]I need Code: http://www.hellhorror.com/demon-names-16.html Code: http://www.hellhorror.com/demons/demonology/16/DYNAMIC-NAME.html How may I do it?? In routing, a seperate file that checks the segment then checks the DB and inserts the file-name? Best optimized solution please.[/quote] Can you explain how you get your original ==> http://www.hellhorror.com/demon-names-16.html Is a user typing it into a browser, from a database, Codeigniter link, link from another webpage, etc
[eluser]Code Arachn!d[/eluser]
Well if you want CI to handle this - I still think you need some sort of way to list the urls that you want redirected - unless you just modify your query and then setup your $route[':any'] to go to a custom method on your controller to redirect to the new page. That's one option.
[eluser]RaZoR LeGaCy[/eluser]
how would I actually code that. I only understood the $route[':any'] and where that goes. The rest just blew over my head LoL Sorry A little explaination please
[eluser]esra[/eluser]
You can probably write a small library with a method using the PHP magic __autoload method in combination with a regular expression composed of the fixed portion of the filename, plus the dynamic part of the file name. Do a web search on 'PHP __autoload' (that is, one word composed of two underscores followed the string 'autoload'). Then load the library in your controller to use whatever you call the autoload method. |
Welcome Guest, Not a member yet? Register Sign In |