My Laravel 5 Application is installed under the Directory Name:
MyAccount
I have following Url in the application:
http://localhost:1234/laravel/MyAccount/public/allskills
This is due to below route:
Route::get("/allskills", "Skills\SkillsController#index");
I am trying to change my Url to below:
http://localhost:1234/allskills
Question: Am I missing any setting in the above routing code ?
I'd recommend using laravel homestead. There are plenty of tutorials online (including screencasts on YouTube) that guide you through it. You can map a url like
"skills.app" to your MyAccount/public directory, so it can be accessed as
skills.app/allskills
If you want to find out more, check outt this short video series on YouTube, but of course if you don't want to go to these lengths you could use one of the answers already given.
Related
I'm working on an application using php framework Laravel.
I've encountered a problem since I need to open a modification form with two parameters. I pass them in my url like so:
<tr class="beBlack" onclick="document.location = '/showGriefs/{{$data->No_Grief}}/{{$data->No_Employe}}'">
(I know that it is sketchy to create a link within a table but I need the url to change according to which row is clicked/selected)
and I receive them in the following route:
Route::any('/showGriefs/{No_Grief}/{No_Employe}', 'GriefController#showGrief')->name('showGriefs');
My problem is that I don't want my url to change, because, with these url changes, my application can't find the files (CSS, JS and Plugins). And since laravel is using the public directory to store all those files, it's destroying my page. The only errors I get are some missing files error.
I've searched the internet a lot but didn't found anything, I hope you'll all be able to help me. Thanks.
I know 2 solutions to fix your problem. No need to change route URLs. Just fix asset problem.
1. Use / before asset url
If you use / before url, browser will try to look at resource on the root dir.
For example: if you need http://example.com/assets/img.png then use /assets/img.png. Changing URLs will not affect the asset URLs that starts with / character.
2. Use url helpers for asset URLs
asset('assets/img.png') will change asset url from assets/img.png to http://example.com/assets/img.png
I am upgrading my website from Yii 1.1 to Yii2. In the older site using Yii 1.1, the url can be given as
http://example.com/index.php/controller_name/action_name/queryString/123
But in Yii2 I have to change this request to
http://example.com/index.php/controller_name/action_name?queryString=123
in order to make it work, otherwise I get a 404 Not Found error.
I already know that this feature has been removed in Yii2 Github issue 6866, but since the older site heavily uses this particular feature, I would like to know if there is any workaround, without changing each individual URL in the existing website.
Thanks
You need to enable pretty urls,and the add rules accordingly.
I want to build a image website like this
ex.com/en-us/lion-wallpapers.html
ex.com/en-gb/lion-wallpapers.html
ex.com/en-in/lion-wallpapers.html
and i want to use single image path to be go through in multiple urls
using routing
images/lion/lion.jpg
.....is google only crawls single image with urls ???
or am i need to maintain individual directories and make them to copy on each directory?? so suggest me some best practises and URL srtructure for this ...
For URL structure like this your better off using a framework that has support for routing and then building your website in a Model-View-Controller(MVC) pattern.
This is quite abstracted architectural stuff so I can't really give specific examples.
Any framework that supports routing would work but an example is Zend Framework: http://framework.zend.com/
Here's their documentation on routing: http://framework.zend.com/manual/1.12/en/zend.controller.router.html
With routing you would be able to one lion-wallpapers.html page that then depending on the URL changes the language on the page.
In terms of how google will crawl your site, it will crawl your websites using links from your first page and anything you add to a sitemap. You can help customise how it crawls your website by adding your site to Google Webmaster tools here: https://www.google.com/webmasters/tools/home?hl=en
I'm trying to learn how to develop my website using Laravel 5.
Now i'm working on the languages of the site, but I have some questions that I hope you guys might know how to solve.
I know that the Location service helps a lot when translating the site, but I want something a little more complicated. I want to put a <select></select> tag at the top of my header where the user will have the option to change to another language.
Right now, I have already created the following folders that will have all the information to be translated.
-resources
-lang
-en
messages.php
-es
messages.php
Each messages.php file has the complete directory of the information to be translated.
I know how to do this using pure php ($_SESSION) and jQuery, but I have no idea how to do this with laravel.
I would like that the website has will look like this:
/[about]
/[contact]
/en
/en/[about]
/en/[contact]
/fr
/fr/[about]
/fr/[contact]
Hope you guys help.
Thanks.
EDIT
I just found a laravel package which can help to manage this kind specific issue in the proper way.
The package name is Laravel Localization and it's pretty easy to use.
Link here
Use the directions from here: http://laravel.com/docs/master/localization
Route::get('{locale}/{page?}', function ($locale, $page == '') {
App::setLocale($locale);
// your code
});
And as for the change of the language from a drop down, just redirect the users based on their choice with java script.
Hey guys hope all is good and here's my question: When you click on a Facebook profile the address bar shows the URI named after the account's owner, for example:
Name: John Smith
Facebook URI: facebook.com/john.smith
The question is, how is this achieved to dynamically name a page based on the name of each user. I do not believe Facebook would make a directory named after each user and then add the same html, css, scripts etc in every directory... So if I decided to make a member's page in PHP how would I go about naming it depending on the user's name?
All constructive answers welcome and have a nice day.
If you have used any frameworks before, you'd be familiar with the concept of routing.
I will give you a rough idea which can be reproduced in any framework. There is an assumption that I will make: You have a table which is storing the user's details and it has a field for the custom URL slug.
Now the logic:
Let's say you have a route configured like website.com/user/mr.xyz.
This means that the route for user/query will be set to a controller like User(query).
Now, you check the query value and see if it is present in your database with the customized URL field.
If it matches, then you load that user's profile.
Update
You should see how routes work in Laravel. If you are not aware of frameworks, then you should learn one to understand how these things work.
This is usually acheived through a rewrite module such as apache's mod_rewrite.
This internally changes (rewrites) the url from domain.com/profilename to something like domain.com/profile.php?profile=profilename. You can then access the query parameter using $_GET['profile']. This is actually a feature of apache and not PHP.
The rewrite happens on the server so the browser will still display the friendly url to the user.
Here is a more in-depth article/tutorial.
http://net.tutsplus.com/tutorials/other/a-deeper-look-at-mod_rewrite-for-apache/?search_index=13
Good luck