YiiBoilerplate Url Rewriting - php yii - mod-rewrite

When we configure YiiBoilerplate. we use its frontend by these url
http://localhost/YiiBoilerplate-master/frontend/www/index.php/site/
i want to change this url and access it like
http://localhost/YiiBoilerplate-master/site/index.
how it is possible by mod_rewrite?

Add a .htaccess file to your webserver root:
RewriteEngine on
RewriteRule ^/YiiBoilerplate-master/(.*) /YiiBoilerplate-master/frontend/www/index.php/$1
This gives you access to your app via a shorter URL, but the links within the app still stay in the longer form. To update the URLs within your app, update baseUrl in the urlManager component:
'components' =>
'urlManager' => array(
'baseUrl' => '/YiiBoilerplate-master',
'urlFormat' => 'path',
...
Note: I'd strongly recommend setting up a virtual host.

Related

Why am I getting 404 error on my livewire.js connection?

I am using Laravel 8. "wire:model" also not working because of this.
you need to setup livewire base url
in config/livewire.php
'asset_url' => env('APP_URL', 'http://localhost'),,
then in .env
APP_URL=your_app_url
in config/livewire.php
'asset_url' => url('/'),
You need to setup the livewire app url in config/livewire.php.
'app_url' => url('/'),
Just the following code to your admin or control panel routes:
use Livewire\Controllers\HttpConnectionHandler;
Route::post('livewire/message/{name}', [HttpConnectionHandler::class, '__invoke']);
And remember to override the url using this one linear:
<script>
window.livewire_app_url = '{{route('admin.index')}}';
</script>
More detailed answer could be found here
Laravel - Livewire, how to customize the global message URL?

404 Not Found on sanctum/csrf-cookie path

So I've been building a projet based on laravel. I'm building on a SPA foundation with sanctum as my authorization package. It works perfectly. Then I deploy the project to the server and everytime I try to login there is a 404 error on /sanctum/csrf-cookie.
How could this happen? Is it because the SanctumServiceProvider not working.
The problem is when you define sanctum prefix, the route become something else like this:
you can check your routes with : php artisan route:list
as you can see the /sanctum/ is removed and when you check the route /sanctum/csrf-cookie it will not be and throws 404 error. So you have two options:
add this prefix: 'prefix' => 'api/v1/sanctum'
or
change GET call to api/csrf-cookie
You need to check if you're setting correct axios defaults for your /sanctum/csrf-cookie api call.
You can set it as follows
axios.defaults.withCredentials = true;
axios.defaults.baseURL = "http://localhost"; //Before sending get request
axios.get("/sanctum/csrf-cookie").then(async () => {
//Logic to handle login
});
If defaults are not set properly url becomes http::localhost::8080/sanctum/crf-cookie which is where frontend is serving but instead it has to be http::localhost/sanctum/csrf-cookie
Note: localhost example is just for explanation. For production server make sure your url is correct and api call is on backend.
I solved this issue by adding:
AllowOverride All
to the apache directory config
add in last line inside config/sanctum.php
'routes' => false,
Add in config/cors.php
'paths' => ['*']

How to add username in url before controller/action in yii2

I'm working on a site and I need to customize site URL in such a manner that it will work like <username>/<controller>/<action> after login the user.
I have tried it with followings rules in Yii 2.0 configuration file:-
'rules' => [
'<username>/<controller:(site|comment)>/<id:\d+>/<action:(index|home|update|delete)>' => '<controller>/<action>',
],
But it shows me #404 error. Any Helps?

How to use an IP address for a multi-site in Drupal 8?

This url seems to claim that it's not possible. But also the workarounds on the site doesn't work, and the information is dated. So my question is... why does this work in Drupal 8, when you put it in the sites.php file:
$sites = array(
// URL ==> path
'test.localhost' => 'default',
'test2.localhost' => 'somepath',
);
But not this:
$sites = array(
// URL ==> path
'test.localhost' => 'default',
'127.0.0.1' => 'somepath',
);
And how would I make it work?
It is a known bug dont go that way. You will have to setup additional Virtual Host and setup drupal there. You can also partially link another site and modify only configuration - but it is a filesystem related opration not Drupal nor Apache/Nginx operation.

Sub-domain routing in Laravel on shared hosting

I'm using Laravel framework version 5.1 for my web application that will be run on a shared hosting. Since I have a very limited access to this host, (e.g. I don't have a SSH access, can't create virtual hosts inside the machine etc.) I had to make some tricks to run it smoothly. Here is what I've done so far:
Moved the files inside of the public/ directory to my root directory.
Changed the file paths of auto load registrar in the public/index.php with the new directory.
Everything works as intended except the sub-domain routing. I defined api.myapp.com as wildcard on routes.php but when I try to visit this subdomain, Chrome gives me DNS_PROBE_FINISHED_NXDOMAIN error. Here is the code from routes.php:
Route::group([
'domain' => 'api.myapp.com',
'prefix' => 'v1',
'middleware' => 'cors'
], function () {
// some RESTful resource controllers
});
How can I manage to work this subdomain? What am I missing?
Thanks in advance!

Resources