Laravel 5.4 pretty url - laravel

Is that any ways to change the url such http://localhost:8080/myproject/advertisements to http://localhost:8080/myproject/admin/advertisements always for every URL. I hide the /public and move the .htaccess to root project.

Add a prefix to your route.
https://laravel.com/docs/5.4/routing#route-groups
Scroll down a bit to the Route Prefixes section

Related

Laravel - Root Url suffix and route prefix inconsistency

We have a test site with laravel 4, which is on a subfolder on the server. So it is on thedomain/sitename. This have caused big challenges with routing. The routes became wrong, like: thedomain/about instead of thedomain/oursite/about.
I added a Url root suffix'oursite' by using the Illuminate\Routing\UrlGenerator (following this suggestion).
All urls in the templates became correct, but they don't match anything in routes.php which still treats it without the suffix.
I tried adding a route prefix . Now the urls typed into the address bar worked. But all the urls in the templates became wrong, for instance thedomain/oursite/oursite/about.
So this seems inconsistent - why is the root Url suffix added to all the routes when they are echoed in the templates (like <a href="{{ route('about'); }} ) but they are interpreted without the suffix in routes.php!?
How can I get around that? I thought I was close to solving this. Or could I use route filter to redirect on every link?
Alternative solution: maybe use subdomain like sitename.thedomain.com instead of subfolder. If your server provider not support subdomains, change provider :P

Laravel project custom domain

I am using custom configuration of domain names for my laravel project test as test.local . When I ran this project as test.local in google chrome , it shows laravel homepage. But, when I go to any other routes it shows internal server error.
Can anyone have any solution?
Just add index.php after the url, and then go to specific route
test.local/index.php/login
So in your routes file eg. web.php, do this if you need to, this adds on a domain limitation.
Route::group(['domain' => env('APP_URL', 'test.local')],function () {
//routes...
});
In you .env file, define the app url, you may use https if required
APP_URL=http://local.test
After all, I would strongly suggest you to check you nginx file to see if you are pointing the path to the right one. And also check if index.php is added into the index file property.

How to remove /blog from url in Joomla

I created a Category Blog on my Joomla site but there's a problem. Joomla is adding /blog automatically to urls and as a result, images aren't displayed since blog/images/ doesn't exist. Is there a way to either remove blog/ from urls or correct image links to display /images instead of /blog/images? These are the links:
http://www.gambitchessacademy.com/blog
http://www.gambitchessacademy.com/blog/10-using-time-efficiently-during-a-tournament-game
Thanks very much.
Fist, your real problem is about Relative VS Absolute URLs. See http://kb.iu.edu/data/abwp.html for example.
For example a javascript file on js/jquery.js is a relative URL. If you are on site.com/blog/article.html it will try http://example.com/blog/js/jquery.js. But if you use /js/jquery.js or http://example.com/js/jquery.js you will have your real problem solved.
Note the "/" at start of paths. They make a lot of diference.

How routing is done in codeigniter?

I could not find the .htaccess file in CodeIgniter framework and i'm wondering how do they do route without it? Or it is somewhere hidden?
There is no .htaccess by default provided with codeigniter. They serve it through the index.php. .htaccess is only used to direct the urls to the index.php. This way codeigniter is working in environments where rewriting isn't allowed. Another way of getting controller and function is by query strings.
Anyway the actual routing is done in system/core/Router.php so you can read the code. Since Codeigniter is open source application that can't be hidden.

Whats the purpose of Index.php in MVC Frameworks?

I want a good understandable description of index.php in MVC Frameworks... I have worked in Magento and Codeignitor...
In Magento URL's index.php is called front controller but in codeignitor what it is?
Plz clear the concept of index.php in MVC Frameworks?
The index is your entry point from where it will dispatch / route your URL to the appropriate controllers/actions. You don't have to name in index.php though, you can give it whatever name you want, as long as you call the file, it won't be a problem.
In codeigniter index.php is the entry point of the application. Its not a controller. It sets your environment, initializes your config/route/autoload etc. and then loads your requested controller.
Generally, index.php mainly works as a bootstrapper. It initializes all most variables and puts your application in a usable state. Almost all calls are routed through it. If you want you can also hide index.php from your visible path using .htaccess. For example in yii you can use this guide: http://www.yiiframework.com/wiki/214/url-hide-index-php/

Resources