Create PURL with CI |
[eluser]love2code[/eluser]
Hi Guys I am new to CI and I am just having a play with it. I want to have a purl type url, currently my url looks like http://localhost/CodeIgniter/main/index/...e.lastname where firstname.lastname is the parameter to method index Url I want to achieve is http://localhost/CodeIgniter/firstname.lastname I've already referred to http://ellislab.com/codeigniter/user-gui...uting.html Can anyone suggest exactly what should I map it to. Thanks Chirdeep
[eluser]Jagar[/eluser]
use the routes.php file to do that Try this it may work: Code: route['(:any)'] = "main/index/$1"; Hopefully it'll work
[eluser]love2code[/eluser]
It does work and thanks for that but now it redirects all other hyperlinks to same page i.e. Main/index Controller
[eluser]Dam1an[/eluser]
as higher routes take precendece, and easy way to solve it is to put all you're other controllers above that route
[eluser]love2code[/eluser]
Sorry but I am not sure what you mean by that. If you are referring to routes.php, that's how it looks $route['default_controller'] = "main"; $route['scaffolding_trigger'] = ""; $route['(:any)'] = "main/index/$1"; I've also moved $route['(:any)'] = "main/index/$1"; to the top but that doesn't change anything. Apologies if I didn't get you right.
[eluser]TheFuzzy0ne[/eluser]
This sounds to me like it might be a problem with either your htaccess file, or your CodeIgniter configuration. In the config.php file, I recommend you try the various uri_protocols, and see if they help. Sometimes REQUEST_URI or QUERY_STRING seem to help. If this doesn't help, please post your htaccess file.
[eluser]Dam1an[/eluser]
Create a route above Code: $route[’(:any)’] = “main/index/$1”; Code: $route['(controller1|controller2|controller3)'] = $1; (You'll also need to add for other methods in those controllers
[eluser]love2code[/eluser]
DirectoryIndex index.php RewriteEngine on RewriteCond $1 !^(index\.php|includes|images|css|js|robots\.txt|favicon\.ico) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
[eluser]TheFuzzy0ne[/eluser]
Sorry, it's just occurred to me that I totally misunderstood the question. That'll teach me not to start reading half way down the page... If I understand the problem now, I think a rout like this might help. I haven't tested it, but I think that's a good place to start. Code: $route['([A-Za-z]+\.[A-Za-z]+)'] = 'main/index/$1';
[eluser]Dam1an[/eluser]
[quote author="TheFuzzy0ne" date="1241204763"]Sorry, it's just occurred to me that I totally misunderstood the question. That'll teach me not to start reading half way down the page... If I understand the problem now, I think a rout like this might help. I haven't tested it, but I think that's a good place to start. Code: $route['([A-Za-z]+\.[A-Za-z]+)'] = 'main/index/$1'; Think you might want to also add a '-' to the surname part, for double barrel surnames (such as mine) |
Welcome Guest, Not a member yet? Register Sign In |