I created a laravel project and I added to the resources/views : 2 blades,
home.blade.php
restaurants.blade.php
In laravel 5.4, I created a route in web.php
Route::get('/', function () {
return view('home');
});
Route::get('restaurants', function () {
return view('restaurants');
});
when I open my project localhost/food/public
the home blade is opening.
When I click on restaurants, the URL changes to : localhost/food/public/restaurants and giving me :
Sorry, the page you are looking for could not be found.
1/1
NotFoundHttpException in RouteCollection.php line 179:
screenshot routes listing:
screenshot views folder:
htaccess :
<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>
Your image is showing that your project is in htdocs/bitfood, and you are assuming htdocs/food instead.
So try open:
http://localhost/bitfood/public/restaurants
If the page does not load correctly then try open:
http://localhost/bitfood/public/index.php/restaurants
..in order to check if the problem could be raised from .htaccess cause it could not be read.
Copy .htaccess file from public folder to root folder and try again.
It will remove the public/index.php from your URL.
Then try this URL
localhost:8000/bitfood/restaurants
Related
I'm trying to set locally a project that run on the web on a NGIX server. This is the htaccess i have downloaded:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~sitename/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~sitename/index.php [L]
</IfModule>
I'm trying to run it locally on an Apache server(on mamp) . It have placed the project in a folder on the server root:
http://localhost/sitename/
But i get a blank page.
I can access a specific internal page (and only that one) if i remove the tilde
~
Even without the tilde, i can't access the homepage of the project.
So what i'm doing wrong?
How the tilde works in this context ?
EDIT
my mod_rewrite is loaded/enabled
I am using laravel 5.4 default authentication system and it is working fine in localhost but when i upload my project to server, it is breaking. when i fill mail and password, it return back me 404 file not found error.
My site url is http://www.happycoder.me/imsRever2.0
You need to configure the .htaccess file as follows:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^imsRever2.0
RewriteRule ^(.*)$ imsRever2.0/$1 [L]
Otherwise, the main web server will not the routing, vs laravel causing the 404 error when the file isn't found.
My htaccess file is below what things i need to change
Options -MultiViews
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}]
So let us say that my website is www.example.com and I have a contact.html page in the root. The URL normally shown in the address bar is: http://example.com/contact.html
For my site, I want the URL to have:
no www
no .html
a trailing slash
So the final result should look like this: http://example.com/contact/
Condition No. 1 is default, so that doesn't bother me.
For Condition 2 (no '.html'), I have the following code into my .htaccess file place in the root directory:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
...and it works perfectly.
Now coming on to Condition 3 (enforcing trailing slash), I have the following code into the .htaccess file before the 'Condition 2' rewrite commands:
RewriteEngine On
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
...this does not work; The page redirects to the Error 404 page and the address bar shows: http:/example.com/404.html... YES, with the trailing slash :/
What am I doing wrong?
I have a folder called archives in the root directory of which I want indexing to be done. So I simply added a .htaccess file in the 'archives' folder and added the following, simple code:
Options +Indexing
But it doesn't work; I get redirected to the Error 403 page! I'm 99% sure that it is due the .htaccess file in the root directory.
Try with:
RewriteEngine On
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.+) %{REQUEST_URI}/ [R=301,L]
# remove html
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^ %1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteRule ^([^\.]+)/?$ $1.html [NC,L]
I installed yii2 from composer and wanted to remove index.php.
I tried doing this:
in config->web.php:
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
],
],
in web->.htaccess:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
I even checked if .htaccess file works by running deny from all and it worked, but this script doesn't or at least I dont know why.
Some stuff what I noticed:
When I enable 'showScriptName' => false, footer of the page doesn't show up
When I try to open midori.dev/web/site/index it shows:
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
midori.dev.lv
Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.5.19
ps. I have configured hosts file and vhost file for midori.dev instead of localhost.
Where is the issue?
Try this:
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
If you are using linux
change httpd.conf file
AllowOverride All
if you create a virtual host,
your file should look like this
DocumentRoot "/path/to/web"
RewriteEngine on
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
# ...other settings...
I'm trying to strip all index.html file & extension exactly like my index.php rule works.
Meaning that instead of
www.discretix/modules-hdcp/index.html
There should be
www.discretix/modules-hdcp/
It works for index.php but in index.html it Doesn't.
I'm using wordpress and my server is apache.
These are my htaccess rules:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~discretix/
RewriteRule ^index\.php$ - [L]
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~discretix/index.php [L]
</IfModule>
The following rule will redirect the user from either index.html or index.php to the folder (this will be reflected in the clients browser address bar) using a 301 redirect (moved permanently), you might want to change this to 302 redirect (originally temporary redirect, but now commonly used to specify redirection for unspecified reason)
RewriteBase /~discretix/
RewriteRule ^index\.(html|php)$ ./ [R=301,L]