Welcome Guest, Not a member yet? Register   Sign In
url routing to dynamic file name
#1

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

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

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

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

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

Still wondered how to do this
#6

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

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

[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
#9

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




Theme © iAndrew 2016 - Forum software by © MyBB