How to pass an URL as a query string? - laravel

I'm trying to pass an url to a controller.
http://something/index.php/api/http%3A%2F%2Fengadget.com
I get 404 Not Found error.
My route
Route::any("/api/{url}", "ApiController#parse");
How do I configure a route or controller to make it work?

Route::any("/api/(:all)", "ApiController#parse");
http://laravel.com/docs/routing#wildcards
You use (:all) to catch the rest of the URI

How about without the / in front of "api"?

Related

How to get guarded_name of route I get from getRoutes method on Laravel

I want to get guarded_name of route I get from getRoutes() method on Laravel.
I can get route name by getName() method. But how to get wether the route is guarded for web or api of that route name?
I found answer from group discussion.
$route->getAction('middleware')
Thank you for your responses.
If you want to know the middleware applied on the route
Route::current()->computedMiddleware;

How to hide function and parameter from url in codeigniter?

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.

Codeigniter - retrieve parameter without controller name in URL

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());
}

codeigniter route removing function_name in url

I got stack on this in Codeigniter route, What do I want is to remove the function_name in url to be able to have a short url.
Here is the example want to have in my url
http://mysite.com/controller_name/function_name/id
to this
http://mysite.com/controller_name/id
Is there any other solution to have this if cannot be done in route? thanks!
If the above didn't work you could try:
$route['controller_name/(:num)'] = 'controller_name/lookup_function/$1';
Not much different from what was already suggested other than a hard coded controller name.
You can probably do it by trying:
$route['([a-z]+)/(\d+)'] = "$1/method/$2";
That is if you don't need to change the name of your method.

Codeigniter URI Routing Issue

I have the following URL
domain.com/name/details/12345
I want it so if someone types in
domain.com/name/12345 it goes to the above
I am using $route[‘name/details/(:num)’] = ‘name/’;
But I get a 404 error when I try it.
From looking at the documentation:
http://ellislab.com/codeigniter/user_guide/general/routing.html
It looks like what you want is:
$route['name/(:num)'] = 'name/details/$1';
The route name/12345 is matched and routed to name/details/12345

Resources