Home > Back-end >  Laravel 8 route not working when .com is there
Laravel 8 route not working when .com is there

Time:08-08

I am in a strange stitaution. I have a very simple laravel application to check licence status. My example route is as below:

https://sign.abcd.com/get-license/pro/testingdomain.com

If I run the above url, its giving 403 forbidden error. But If I just change .com to anything else, its working fine. eg:

https://sign.abcd.com/get-license/pro/testingdomain.con // working fine

Where I am doing the mistake, plz advice.

Route File:

<?php

use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    return view('welcome');
});

Route::get('/get-license/{type}/{domain}', [\App\Http\Controllers\License::class, 'license_status']);

Controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class License extends Controller
{
    public function license_status($type, $domain)
    {
        $domain = str_ireplace(['http://', 'https://','www.'], '', $domain);
        $find = DB::table('licenses')->where('type', $type)->where('domain', $domain)->count();
        if($find >0){
            return 'Ok';
        }
        return 'No license found for this domain';
    }
}

Htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (. )/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

CodePudding user response:

in Route File:

Route::get('/get-license/{type}/{domain}/{domain_type}', [\App\Http\Controllers\License::class, 'license_status']);

Controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class License extends Controller
{
    public function license_status($type, $domain,$domain_type)
    {
        $domain = str_ireplace(['http://', 'https://','www.'], '', $domain);
        $find = DB::table('licenses')->where('type', $type)->where('domain', $domain.'.'.$domain_type)->count();
        if($find >0){
            return 'Ok';
        }
        return 'No license found for this domain';
    }
}

usage :

https://sign.abcd.com/get-license/pro/testingdomain/com

i hope it was useful

CodePudding user response:

It was my mistake. My server's mode security rules did all these :(

  • Related