CodeIgniter Forums
url routing to dynamic file name - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: url routing to dynamic file name (/showthread.php?tid=2760)



url routing to dynamic file name - El Forum - 08-22-2007

[eluser]RaZoR LeGaCy[/eluser]
I need
Code:
http://www.hellhorror.com/demon-names-16.html
to go to
Code:
http://www.hellhorror.com/demons/demonology/16/DYNAMIC-NAME.html
with a header of 301 permanent redirect

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.


url routing to dynamic file name - El Forum - 08-23-2007

[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?


url routing to dynamic file name - El Forum - 08-23-2007

[eluser]RaZoR LeGaCy[/eluser]
I have hundreds in different sections so this is much needed


url routing to dynamic file name - El Forum - 08-23-2007

[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().


url routing to dynamic file name - El Forum - 09-01-2007

[eluser]RaZoR LeGaCy[/eluser]
lets try again in the forums

Still wondered how to do this


url routing to dynamic file name - El Forum - 09-01-2007

[eluser]John_Betong[/eluser]
[quote author="RaZoR LeGaCy" date="1187864348"]I need
Code:
http://www.hellhorror.com/demon-names-16.html
to go to
Code:
http://www.hellhorror.com/demons/demonology/16/DYNAMIC-NAME.html
with a header of 301 permanent redirect

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
 


url routing to dynamic file name - El Forum - 09-01-2007

[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.


url routing to dynamic file name - El Forum - 09-01-2007

[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


url routing to dynamic file name - El Forum - 09-01-2007

[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.