Welcome Guest, Not a member yet? Register   Sign In
'.' in the URL...
#1

[eluser]adt6247[/eluser]
I'm trying to come up with a way of generating a sitemap.xml dynamically using a controller. I basically want the URL to look like this:

http://www.mysite.com/sitemap.xml

Unfortunately, I can't add a '.' in the classname. I currently am setting up a route to have it redirect /sitemap.xml => /sitemap/, and that works, but I'd like it to be more transparent. I'd like to do this without writing to a static file on the server, like some implementations suggest. Is this possible?

Is anyone working on support for URL aliasing in CI?
#2

[eluser]TheFuzzy0ne[/eluser]
Is there any reason why your sitemap should not be a static file?
#3

[eluser]CroNiX[/eluser]
Agree with TheFuzzyOne. Why not just set up a cron job to generate your static sitemap.xml file? It can just call yoursite.com/gen_sitemap or something once a day or however often you need it.
#4

[eluser]adt6247[/eluser]
[quote author="CroNiX" date="1237191492"]Agree with TheFuzzyOne. Why not just set up a cron job to generate your static sitemap.xml file? It can just call yoursite.com/gen_sitemap or something once a day or however often you need it.[/quote]

I don't have access to cron on my hosting system. I'd prefer this to be dynamic and portable.
#5

[eluser]adt6247[/eluser]
Never mind... got it working via URL rewriting.
#6

[eluser]TheFuzzy0ne[/eluser]
You should still be able to call the function dynamically as needed. The sitemap.xml should be called by the script that's responsible for altering the output. If a new part of the site is added, the script that added it can call the script to regenerate the sitemap. If you absolutely must do it the way you're asking, the only thing I can think of would be to make your config.php file a little something like this:
Code:
$_SERVER['REQUEST_URI'] = '/sitemap.xml';

if (substr($_SERVER['REQUEST_URI'], 1, 12) === 'sitemap.xml')
{
    $config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-\.'; # Allow a .
}
else
{
    $config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
}
The above code is untested, but hopefully helps to illustrate my point.

You'd then need to add a route to your routes.php:
Code:
$route['sitemap\.xml'] = "sitemap";




Theme © iAndrew 2016 - Forum software by © MyBB