Viewed   495 times

Problem:

my routes not working except the root home page, I'm searching for two days to find a solution to this problem and what I found that I should change .htaccess file but solutions didn't fix any for my case, at first the url localhost/quotes/public was working well with me, but at some point I'm not sure what is it this issue showed up

what I tried:

  • create another route and I made sure that no routes are working only home route, still not working except home
  • tried to change OverrideMode on my XAMP from None to All, didn't fix any
  • tried to type manually localhost/quotes/public/index.php BOOM everything works ..

my htaccess file:

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

        RewriteEngine On

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

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

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

working on:

  • Windows 10
  • XAMP
  • Laravel 5.2.35

 Answers

3

The problem is that your .htaccess is rewriting everything to the frontcontroller, which is normally located at {host}/index.php. In your application however it is located at {host}/quotes/public/index.php.

So you have 2 options:

1. virtual host
Set up a virtual host in your XAMPP Apache that points ie. myapp.local to htdocs/quotes/public Here is an example of how to achieve this: how to create virtual host on XAMPP. (Don't forget to add the host to your hosts file and have it point to your local macine on 127.0.0.1) You can then access your application on myapp.local/whatever-route-you-define. Alternatively you forget about XAMMP and install the homestead virtual machine, which comes preconfigured for this.

2. rewrite rule
Change you rewrite rule to rewrite all requests to quotes/public/index.php in stead of index.php. I'm no htaccess expert, but I believe it should be as simple as changing this:

RewriteRule ^ index.php [L]

to this:

RewriteRule ^ quotes/public/index.php [L]

Do note that you'll still need to access your application trough localhost/quotes/public/whatever-route-you-define which is not ideal imo. Your dev version should be as close to your live version as possible, and if you start working with absolute and relative paths and stuff in your code things will become a mess sooner rather then later.


Personally I would go for Homestead, I use it all the time and it works great once you have it running.

Btw, the reason why localhost/quotes/public/index.php is working for you right now is because RewriteCond %{REQUEST_FILENAME} !-f tells Apache not to rewrite any requests to files that actually exist (otherwise you wouldn't be able to access static assets like your css).

Thursday, September 15, 2022
 
jts
 
jts
2

you need to put all jobs

$schedule->job(new Job1)->everyMinute(); 
$schedule->job(new Job2)->everyMinute(); 
$schedule->job(new Job3)->everyMinute(); 

under schedule() function in kernel.php and than scheduler will handle all the jobs.

Friday, December 9, 2022
 
2

Login function needs user of type Authenticatable and you just given email which is string thats why you get this error, Either use Auth::loginUsingId($id);

 $user = User::where('email','=',$email)->first();
 Auth::loginUsingId($user->id, TRUE);

Or just

Auth::login($user);
Saturday, August 13, 2022
 
2

If you have done 2 steps already have you change the index.php having vendor folder path inside remove the /../ and everything work fine

$app = require_once __DIR__/../'/bootstrap/app.php';

to

$app = require_once __DIR__.'/bootstrap/app.php'; 
Sunday, December 25, 2022
 
jiinxy
 
25

Yes, we've noticed this ourselves. Windows 2008 (and Win 7 for that matter) will use certain tunneling IPv6 addresses. You can turn them off by setting a registry setting. It's described here:

http://support.microsoft.com/kb/929852

HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpip6Parameters

Create a new 32-bit DWORD named "DisabledComponents". Set it to 0x01 to disable the tunneling interfaces.

Wednesday, November 30, 2022
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :