Welcome Guest, Not a member yet? Register   Sign In
Remove Module Name from URL
#1

[eluser]AndrewTurner[/eluser]
Hi All,

I'd like to remove the name of one module (frontend module, as I'd like to keep the other modules in the url) from the url.

E.g. http://www.site.com/frontend/post/view/1

It's the frontend part I'd like to remove as I've got an admin module (that's fine having that module name in the url), although for the frontend it isn't needed as it's what is being displayed at the root level, just not sure whether it's best done through Apache or routes, or neither and a different approach.

I'd appreciate any help.

Thanks everyone!
#2

[eluser]matt.asbury[/eluser]
Hi Andrew

Do you mean you would like to change the URL from http://www.site.com/frontend/post/view/1 to http://www.site.com/post/view/1 but still hit the frontend Controller? I'm not 100% sure, but I don't think this is easily possible. The trouble you will have is getting codeigniter to differentiate between a function call (/post/ in this example) and a class.

I suppose it might be possible to create a custom Controller (MY_Controller) which checks whether a class exists (class_exists function) using the first segment of the URL. If it does, go to that class and if not go to the frontend class and use the first segment of the URL as the function.

I don't think it would be possible to use a .htaccess file to achieve this as you would not be able to use a RewriteRule to say what a class is and what a function is.
#3

[eluser]AndrewTurner[/eluser]
Yeah, That's what I'd like to do.

I'll see what I can do regarding a custom controller, although a 'hackish' style workaround would be to just dump my app files for the frontend module into the root app directory (in the respective mvc folders), although It'd go against the module principle.
#4

[eluser]InsiteFX[/eluser]
_remap();

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB