0

I've created an about page in Laravel and pointed it to routes, but the problem is when I go to the URL: http://localhost:8080/bsms/public/about it doesn't work, and it says

Sorry, the page you are looking for could not be found.

However, http://localhost:8080/bsms/public/index.php/about is working fine. I want to my URL free from index!

These are my routesenter image description here

4
  • What are you using to server the site i.e. MAMP, WAMP, XAMPP, php's built-in server etc.? Commented Mar 25, 2019 at 21:36
  • @RossWilson I'm using xampp Commented Mar 25, 2019 at 21:53
  • You should have your public folder set as the web root for the project. Have a look at 5balloons.info/install-laravel-5-7-xampp-windows Commented Mar 25, 2019 at 22:01
  • can you share the directory structure Commented Mar 26, 2019 at 10:20

3 Answers 3

2

go to /public/index.php and add blow code after define('LARAVEL_START', microtime(true));

/*
 * redirecting addresses with /index.php/
 * */
$url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
if (strpos($url, '/index.php')) {
    $url = str_replace('/index.php', '', $url);
    header('Location: ' . $url);
    die();
}
Sign up to request clarification or add additional context in comments.

Comments

0

Are you in localhost?

Try adding this line to your .htaccess file in your public folder:

RewriteBase /

So it should be like this:

<IfModule mod_rewrite.c>
RewriteBase /
<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]

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

If it doesn't work, try to give some more details about your project environment.

Also, url should be pointing to something like this: bsms.test or similar.

1 Comment

Ok, open console and type: php artisan serve Point to the url given, normally: 127.0.0.1:8000
-1

You should be able to access your about page through this url http://localhost:8080/bsms/about (taking in consideration that your view files are in resources folder and not in public folder).

Give it a try using these comands

php artisan config:clear
php artisan cache:clear
composer dump-autoload

And let us know how it goes.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.