I have defined route for particular URL, but with route params is not working, with same URL without route params is working, here is my URL for that
https://XXXX.com/username/post/details/10425/50
And its for i have defined below route
$route['(:any)/post/(:any)/(:any)/(:any)'] ='post/details/$1/$2';
10425 and 50 is my 2 params, which is not working for me, can anyone please help me to resolve this issue?
$route['(:any)/post/(:any)/(:any)/(:any)'] ='post/details/$1/$2';
Should be :
$route['(:any)/post/(:any)/(:any)/(:any)'] ='post/details/$3/$4';
Since it's the 3rd and 4th parameters, not 1st and 2nd.
Related
this is my URL.
http://localhost/savyy/home/home_page/Islamabad
i want to show it like
http://localhost/savyy/home
i m using uri routing code
$route['home/(:any)'] = 'home/home_page/$1;
but nothings happen...it shows same URL. can anyone please help me ? please tell me how to hide function name and parameter.
I dont think it will work that way, the request is the route to controller. the request uri will be the same. you will still have the "home/home_page/islamabad" in your url. unless you redirect with the home_page() to home() and save the islamabad in a session.
I would like to use a URL as route parameter in Laravel. Here is the route declaration from my web.php
<?php
Route::get('/url/{id}/{url?}',
'URLController#find')
->where('url', '(.*)');
This is working fine if the "url" parameter doesn't have its' own query parameters. Yet this is not working as expected:
http://www.somedomain.com/productsdetails?prodid=44296
When I pass the above URL, it just get the http://www.somedomain.com/productsdetails part of the parameter. Laravel couldn't resolve the part after the question mark.
Do you know any workaround for this?
I'm trying to retrieve string as parameter using following URL scheme:
www.myapp.com/[String]
Is there any way I can do this?
*Based on my research, Codeigniter doesn't accept string parameters unless I include the Controller's name in URL: www.myapp.com/[Controller Name]/[String]
But this doesn't solve my problem :(
You're right, CI requires controller name at URI, but You can use default_controller.
At config/routes.php add route rule $routes['(:any)'] = 'welcome/index';, remove index.php from Your URL (there're many tutorials and how-to for this), and at last useuriclass at Yourindex()method ofwelcome` controller:
function index(){
var_dump($this->uri->uri_string());
}
I am having trouble removing the controller name from my url path on my localhost.
i have this url - localhost:8888/localhost/site_name/
i have been able to remove index.php from the url using my htaccess similar to http://codeigniter.com/wiki/mod_rewrite so that:
localhost:8888/localhost/site_name/index.php/controller_name
is now:
localhost:8888/localhost/site_name/controller_name/
but i can't remove the controller name from the path so that:
localhost:8888/localhost/site_name/controller_name/function_name/
becomes:
localhost:8888/localhost/site_name/function_name/
I am using only one controller, and i have added:
$route['^(function_name1|function_name2|function_name3)(/:any)?$'] = 'controller_name/$0';
$route['^(?!ezstore|ezsell|login).*'] = "home/$0"; /*similar variation i tried*/
and other variations to my routes file but it does not have any effect. i also tried using the _remap function but that does not help in this case.
Any help will be appreciated! Thanks
You can use a wildcard route,
$route['(:any)'] = "controller_name/$1";
Then when if you go to http://localhost/function_one/param1
it will call the controller controller_name the function function_once and pass param1 as the first parameter.
nb: I must point out, using only one controller for an entire site does raise warning bells for me, you may want to get your code design checked out, but that's just me.
Can I have two params in one url such as:
localhost/post/image/id/something/else/value
where id is a param and something is the value and where else is the param and value is the value.
In zend I can only get the first param via:
$this->_getParam('id');
This method doesn't work for the second parameter.
Any ideas?
It should be working fine. Make sure you application.ini and plugins are doing default routing.
Default Zend Route looks like this:
With Out module
domainName/controller/action/var1/value1/var2/value2
With module
domainName/module/controller/action/var1/value1/var2/value2
Check following link for default Zend routes:
http://framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.default-routes
use ? to separate the variables in the querystring
something like http://localhost/post.php?imgID=1&otherValue=othervalue