I have wordpress installed:
example.com
and laravel /public dir (which is accessed from api.example.com)
example.com/api
How do i access a laravel route say /play
from example.com/play
currently i have this example.com/play/play
showing the correct laravel route, but i need it to go up a level.
The setup index.php in /home/public_html/play
require __DIR__.'/../../laravel/bootstrap/autoload.php';
$app = require_once __DIR__.'/../../laravel/bootstrap/app.php';
this correctly points to the /home/laravel
for example
then the routes file is
Route::group(['prefix' => 'play'], function () {
Route::get('/', ['as'=>'/', 'uses'=>'Controller@play']);
});
i have added RewriteCond %{REQUEST_URI} !^/(play/.*)$
to root .htaccess so wordpress doesn't take over.
and finally this is where i am hitting the problem:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /play/index.php [L]
</IfModule>
which is located in /home/public_html/play
So how do i show the laravel route in the /play dir? Can this be achieved with rewrite? Can i pass a parameter to laravel to tell it to start /play as the root?
Laravel route model binding provides a convenient way to automatically inject the model instances directly into your routes. For example, instead of injecting a user's ID, you can inject the entire User model instance that matches the given ID.
The namespace on the route, is to define where the controller is for that route in Laravel. You don't have to use ->namespace() , you can do Route::get('something', 'MyNamespace\SomeController@method'); Level 2.
All Laravel routes are defined in your route files, which are located in the routes directory. These files are automatically loaded by your application's App\Providers\RouteServiceProvider. The routes/web.php file defines routes that are for your web interface.
This is not a great big feature, but it simplifies your code and removes a couple of files. Let’s define a route with Route::view, to access contact page. with the use of Route::view, we don’t have to define the controller or a closure to render a view, you can define a URI and a path to a view file.
When injecting a model ID to a route or controller action, you will often query the database to retrieve the model that corresponds to that ID. Laravel route model binding provides a convenient way to automatically inject the model instances directly into your routes.
Your global middleware stack is located in your application's HTTP kernel ( App\Http\Kernel ). For more information on CORS and CORS headers, please consult the MDN web documentation on CORS. When deploying your application to production, you should take advantage of Laravel's route cache.
When you have multiple applications that you want to access it from single domain, the best implementation is to boot different server for each application. The you can set up proxy from the main application to other applications.
You can boot apache2 server for your laravel application with setup like this
<VirtualHost 0.0.0.0:8080>
DocumentRoot "path-to-laravel-app"
<Directory "path-to-laravel-app">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Allow from all
</Directory>
</VirtualHost>
Then set up proxy in your wordpress application .htaccess
file like this
ProxyPass "/play" "http://locahost:8080/play"
ProxyPassReverse "/play" "http://locahost:8080/play"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With