Base Path not recognized on live server - codeigniter

My path to media folder (css) worked fine on localhost but on live server it does not recognize it. All I changed was system and application path in index.php to website/system and website/application. URL-helper is auto-loaded. Base_url is set to http://website.com/
Here is the folder structure:
Root-Folders: Apache Logs, Error Logs, Website
Website-Folders: Application, Media, System
Media-Folders: css
CSS-File: style.css
Here is e.g. my css inclusion:
<link rel="stylesheet" type="text/css" href="<?php echo base_url('media/css/style.css'); ?>" />
When I include the css internally it works so it is definetly a path-issue. I tried several things with base_url but yeah no success. Thanks for any help!
My .htaccess file:
Options -Indexes
Options +FollowSymLinks
# Set the default file for indexes
DirectoryIndex index.php
php_flag short_open_tags on
<IfModule mod_rewrite.c>
# mod_rewrite rules
RewriteEngine on
# The RewriteBase of the system (if you are using this sytem in a sub-folder).
#RewriteBase /cmp/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .$ index.php/$1 [L,QSA]
</IfModule>
# If Mod_ewrite is NOT installed go to index.php
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>

You need to move the contents of the Website folder to the root and try once.

Try this
<link rel="stylesheet" type="text/css" href="<?php echo base_url().'media/css/style.css'; ?>" />

Related

I have uploaded laravel project but its showing index of/admin. how to fix it?

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;

Laravel show blank page in local ubuntu 20

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

Laravel version 5.7 root show index of page

Recently I am start using Laravel, and I develop a website in my local which works fine, but when I deploy it to a droplet in DigitalOcean, the root shows an index Of page.
Screen Capture is here
And when I navigate into the public folder, it shows a 500 error.
I have tried to include a few different .htaccess, which does not solve the problem. And my current .htaccess is below
DirectoryIndex index.php
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/index.php [L]
The line "Options -MultiViews" is actually part of the .htaccess code too.
Could anyone please help me to solve this problem?
Thank you in advance.
See more here
In the server config file is the AllowOverride set to All or None? If its set to none all .htaccess changes will be ignored.
<Directory /var/www/YOURAPP/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Don't forget to generate a key...
php artisan key:generate
https://laravel.com/docs/5.7/installation

Laravel hosting error 500

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>

The requested URL was not found on this server

Environment
Laravel Version : 4.2.17
PHP Version : 5.6.1
MAC OS X : 10.11
MAMP : 3.5
Description
The project loading fine on home page.
Anything else, but that I got this.
The requested URL /login was not found on this server.
Attempt
check routes
I have that routes declared in my routes.php file
Route::get('login',array('as' => 'login', 'uses' => 'AuthController#showLogin'));
apache settings
MAMP > Apache Settings
<Directory />
Options Indexes FollowSymLinks
AllowOverride All <--- I've changed from 'None' -> 'All'
</Directory>
Restart my MAMP, and same error occur
Question
Why do my server kept throwing me that error ?
What should I check ? Apache Settings of my MAMP ? or my PHP ? or my Laravel ?
After stuck on this more than a day, I've learned that I don't have .htaccess in my public\ folder of my laravel project.
I created a public\.htaccess with this content in there
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Reboot my MAMP
All of that nonsense is no-longer happening.
Hope this answer help someone like me

Resources