I have this folder structure for laravel app I uploaded it online to cpanel.
But if I access this laravel app in browser, I need to access it like this
http://venkasure.com/venkasure/public/
where as I was expecting it to be as http://venkasure.com
I am not sure whether it's because of .htaccess settings .
My .htaccess file in public folder
<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>
I don't have much experience in configuring htaccess files, need help or do I need to add htaccess file in root.
Related
I have a Laravel 7 project and I'm using XAMPP for my localhost. The project folder is in C:\xampp\htdocs\eegore-new. I've copied my .htaccess file from the public folder (the other one still exist in public directory), and put it in to the root directory and changed the server.php into index.php so I can now access my my application via localhost with this url -> http:://localhost/eegore-new. But once I clicked my login button on that page, it redirected me to http:://localhost/login which shows 'Object Not Found, Error 404' while it should redirected me to http:://localhost/eegore-new/login so the page can load correctly.
I've changed my APP_URL in .env file to <'http:://localhost/eegore-new-copy'> and tried to change my .htaccess file in my root folder.
This is my folder structure :
My folder structure screenshot
This is the .htaccess in my root folder, I tried RewriteBase but its not working:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteBase /eegore-new/
# 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>
And this is the .htacess in my public folder:
<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]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I have to make all the routes functioning just like http::/localhost/eegore-new/login or /user or /other but I'm not really sure what to do or where to start actually and I know nothing about .htaccess.
Any help will be really appreciated, thanks in advance!
When filling on hosting, I faced the problem that you can not select the start folder of the opening. When opening a link юhttps://my-domen/ this opens
to get to the site, enter /public
how to make sure that when you open the site, the public folder is immediately opened on the hosting so you can not configure it . Can I use htaccess or something else? If this helps then the laravel files are a clean project
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]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
In your root folder use this .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
In the public folder use the new clean laravel .htaccess file
I just recently deploy my Laravel app and I want to remove the folder directory. Example:
example.com/laravel/anotherfolder/home
I want to remove the laravel because that is the folder
I have tried searching on google but they don't work, here is my .htaccess
DirectoryIndex public/index.php
<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 ^laravel/(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ public/index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>`
Depending on your shared host provider, you need go on your control panel and change the public directory to laravel/public.
Another solution would be to replace the current public folder by a symlink which links to laravel/public. You'll need an SSH access for this solution.
I'm new in Laravel. I develop a project on my local computer and it works properly. But when I publish it to the server, I just can see the main page and pretty URLs (contain CSS files and all other directories) and Laravel routes doesn't work.
Here is my configurations:
debeian 8
apache
PHP 5.6.24-0+deb8u1
.htaccess content on laravel/public:
<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>
How can I fix this?
I'm using Laravel for my website, but i'm encountering a problem.
My website does not have any public_html or htdocs folder, but the root itself it is already public. Because of this i'm obliged to put all the Laravel files to the root folder.
To who doesn't know, when using Laravel the public folder is generally the subfolder public, therefore right now if I want to access my Laravel web applicaton I have to navigate to http://www.mywebsite.com/public.
I need to edit the .htaccess in order to show from http://www.mywebsite.com/ the subfolder public files and deny any access to the root files.
So http://www.mywebsite.com/public/index.php should be http://www.mywebsite.com/index.php, http://www.mywebsite.com/public/images/logo.png should be http://www.mywebsite.com/images/logo.png and so on.
Now I'm wondering, is it even possible?
Laravel .htaccess original file is:
<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]
</IfModule>
I've been successful to solve this myself by editing the original .htaccess to:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond public/%{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ public/$1 [L,R=301]
# Handle Front Controller...
RewriteCond public/%{REQUEST_FILENAME} !-d
RewriteCond public/%{REQUEST_FILENAME} !-f
RewriteRule ^ public/index.php [L]
</IfModule>