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
Related
I have Wordpress apps inside Laravel. This is what it's looks like.
public
--article
WordPress inside article folder. The reason I do this because I want it to access WordPress like this
{host}/article
There is issue occured. I can access {host}/article/wp-login.php. But when I fill The Login Form out and then send it, I got Laravel 404 Not Found Error Page.
This is weird because several days ago I can do that, but now error occured.
I think I miss some configurations in the .htaccess but I don't know the error.
This is my Laravel .htaccess configuration
# public/.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>
and this is my WordPress .htaccess
# public/article/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteOptions inherit
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /article/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /article/index.php [L]
</IfModule>
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!
In my Dev server which is on my pc, I set up vhost to change my URL to dmb.dev to remove the public in URL so many of my routes started at / slash. After I transfer my project to our test server I configure some settings to allow me to remove public. Now, all assets are working except my routes because I'm still having http://server/dmb instead of http://server I'm getting an error of Failed to load resource: /myurl.
My sample routes
Route::get('/', 'PagesController#index')->name('index');
Route::get('/generate_bing', 'PagesController#generateImage')->name('index.getImage');
Route::get('/users', 'PagesController#showUser')->name('users')->middleware('auth','role:owner');
My root 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
RewriteCond %{REQUEST_URI} (.+)/$
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>
Do I need to change all routes to dmb/etc.. I'm thinking of solution of removing my root folder so it would look like http://server, but there's other project on our htdocs so I need to remain it store in their folders. BTW I'm using xampp
As you have dmb as your folder under public_html, adding one line to your htaccess would solve the issue.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /dmb/ // ADD THIS LINE HERE
# 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]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
I have a problem when uploading a new laravel 5.5 project. When I alter the htaccess in the public_html folder on my server it keeps redirecting. However this problem wasnt there on laravel 5.0. Here's my htaccess from the public_html folder:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
And here's the htaccess in the 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>
Any suggestions on how to solve this problem?
Beside the fact that it is really not good idea to put a Laravel project in your Document Root, you have a problem with your htaccess file in your Root directory.
Additional I would at least protect all files in your root folder from direct access:
<IfModule mod_rewrite.c>
RewriteEngine On
# Fake 404 for all files in /
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^/?[^/]+$ - [R=404,L]
# Protect rewrite loop: exclude /public
RewriteCond %{REQUEST_URI} !^/?public(/.*)?$
RewriteRule ^(.*)$ /public/$1 [L]
</IfModule>
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.