I have a laravel project. When I host it in a subdomain and add the file .htaccess to redirect to the public folder, I get the HTTP ERROR 500. First I thought that the error was from the host, but I changed the project and it worked, so the problem has to be the laravel.
my .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
I don't have any idea to resolve it.
Can any one help me?
I have some legacy apps running Laravel with Apache and for them this is the .htaccess that I use to redirect to the public folder.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Related
I have Laravel 6 running well on my localhost but when I deploy on domainsite.com, it only shows the main page but the rest of links shows 404 page not found. I am using CentOS 7, aaPanel running nginx server. PHP 7.4 MySQL.
I have this config so far.
URL Rewrite:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
fileinfo installed
I have removed in Disabled Functions(putenv and symlink) but still I get the error.
Anyone have tried this? Thank you!
I have uploaded laravel 8 project but its showing index of/admin in when I run the admin page.
Please help me.
Add .htaccess file in project's root directory with content
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
To be sure you set default root folder to public.
If you using Apache you can rewrite with .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Nginx with this:
root /var/www/your_domain/htdocs/public;
I am using ubuntu 20, laravel project run using php artisan serve but when I access the site using this URL laravel-local.com it shows blank page
Could not get any error
sites-available
<VirtualHost *:80>
ServerAdmin admin#MyWebsite.com
DocumentRoot /var/www/html/laravel-local.com/public
ServerName laravel-local.com
<Directory /var/www/html/laravel-local.com/public>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
What I tried
Give project 777 access
Change the ownership
Delete the folder inside the storage/framework
Change the storage folder permission
composer dump-autoload, php artisan cache and config clear
Delete .htaccess file in public folder
I tried all the above steps still got a blank page
.htaccess file in root folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
.htaccess in the public folder
<IfModule mod_rewrite.c>
Options -Indexes
<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>
sites-available
UPDATE: Your vHost config should be defined in "sites-enabled" for the config to actually be applied. Create a symlink from "sites-enabled" to the actual config file in "sites-available". And restart Apache.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
You don't need an .htaccess file like this (which would need to go in the directory above the /public directory) because you have already configured the /public directory as the DocumentRoot in the server config.
If you had also deleted the .htaccess file inside the /public subdirectory then this would have resulted in a rewrite-loop (500 error).
You just need the standard Laravel front-controller (.htaccess file) inside the document root, ie. in the /public subdirectory.
However, you should define the DirectoryIndex (if not already set somewhere in the server config), either in your vHost (<Directory> container) or at the top of your main Laravel .htaccess file (inside the /public folder). If this is not defined then requests to the Laravel directory itself (the homepage) will not be routed through Laravel and will likely result in a 403 Forbidden response (or worse, a directory listing if Indexes have been enabled) from Apache.
For example:
DirectoryIndex index.php
I am using shared hosting.
I have installed my laravel application and i am using unisharp Laravel File Manager.
With the manager, I uploaded file "happy.jpg". it produced url "http://unpluggedworldofmine.com/storage/photos/1/happy.jpg" but i cannot access to the file.
instead, when i use
"http://unpluggedworldofmine.com//storage/app/public/photos/1/happy.jpg", i can see that i has been uploaded properly.
it looks like there is problem with .htaccess
RewriteEngine on
RewriteRule ^/?$ /public/ [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*) /public/$1 [L]
AS i am using shared hosting, i cannot change configuration in httd or others.
i used
php artisan storage:link
to set up link.
can anyone help me with this?
Thanks
On put request via ajax "403 forbidden access to server" is thrown on the page.I am using a shared hosting envirnoment.I dont have access to Server. I have checked related questions here but didn't see a solution that helps me.
Does anyone know how to fix this?
My htaccess file look like this
<IfModule mod_rewrite.c>
AddHandler application/x-httpd-php72 .php
RewriteEngine On
# Removes index.php from ExpressionEngine URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
</IfModule>
my question is possible duplicate of this question PATCH request 403 Forbidden
But I dont know where to insert the code on vhost
File structure
public is moved to public_html and other folders to root directory