0

Here is an example (It's in Laravel 4).. I want my url like this http://example.com/home/SiteLocation and in routes.php I defined Route::get('home/SiteLocation','HomeController@Functionname');

My point is,

  1. Is it possible to use like this SiteLocation (lower case and upper case mix) as url ?

  2. If yes, how to define function in controller for the same ?

Chinmoy
  • 318
  • 5
  • 15

2 Answers2

0

Is it possible to use like this SiteLocation (lower case and upper case mix) as url ?

Yes - it should just work, you shouldnt need to modify your code

If yes, how to define function in controller for the same ?

Your function name in your controller can be anything you like - it doesnt need to correspond to the url. For example this would work:

Route::get('home/SiteLocation','HomeController@siteLocation');

as would this:

Route::get('home/SiteLocation','HomeController@SiteLocation');

and this:

Route::get('home/SiteLocation','HomeController@other');
Laurence
  • 58,936
  • 21
  • 171
  • 212
  • I'm getting Controller method not found. for all the above cases , once i make it Route::get('home/sitelocation','HomeController@getSitelocation'); it works ..! – Chinmoy Mar 28 '15 at 03:27
  • Post your controller code. The "URL" and the "function" in your controller are two different things and are not related – Laurence Mar 28 '15 at 03:28
  • So you should be able to do `Route::get('home/SiteLocation','HomeController@getSitelocation');` - that should work – Laurence Mar 28 '15 at 03:29
  • Same issue ...Controller method not found. here is my code - routes.php Route::get('home/SiteLocation', 'HomeController@getSitelocation'); and in homecntroller public function getSitelocation() { echo "hello!"; } – Chinmoy Mar 28 '15 at 03:34
0

It’s always good practice to avoid using capital letters in your URLs.

Here’s why:

1-If your website is on a Windows server, then www.example.com/about will be handled exactly the same as www.example.com/About.
The Windows server is case insensitive. If your website is hosted on Linux, then those two addresses will be seen as two different pages(You can also provide a regex instead - but this might be a little OTT.).
2-Having Two URLs Lead to the Same Page is No Good for Search Rankings.

See define a case insensitive (part of a) route

Community
  • 1
  • 1
  • -1. Windows machines are only case sensitive for file names - not for URLs. Because Laravel routes all URLs through `index.php` - then they are treated as case sensitive. According to W3 standards - URLs are supposed to be case sensitive: http://stackoverflow.com/q/7996919/1317935 – Laurence Mar 27 '15 at 10:03
  • Also "Having Two URLs Lead to the Same Page is No Good for Search Rankings." is not relevant here. If the URL is case sensitive - then there is still only one URL to the path - so this doesnt apply. – Laurence Mar 27 '15 at 10:06