How to upload laravel 5 project in Linux hosting server? - .htaccess

I am trying to upload laravel 5 project to a live hosted Linux server. When I browse to a url it shows many errors.
Error- 404 Page Not Found
and
Forbidden You don't have permission to access / on this server.
When I check my Error log file
[Mon Dec 28 12:10:57 2015] [error] [client 60.243.107.196] Directory index forbidden by Options directive: /home/riseyourmoney/public_html/vdl/
So I changed my .htaccess file
<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>
There is any routing problem?

Related

Config .htaccess

It's my first time deploying a web app on a hosting and they give me this .htaccess but i've never configured one, i have a root directory then a public_html and at the same level my webpage. i'll show you the directory tree and the content of the .htaccess
root
|
|---project
|---public_html
|---.htaccess
The content of the .htaccess is:
<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 when I enter the website it's showing me a http 403 error: Server or website configuration is blocking you from viewing this page.
I have never configured a website on a hosting so I don't know what i'm doing most of the time...
Thx!!
root
|
|---project
|---public_html
|---.htaccess
Assuming public_html is the document root (where your public facing files and index.php are located) then the .htaccess file should be in the public_html directory itself (not above it).
That is...
root
|
|---project
|---public_html
|------.htaccess
By placing the .htaccess file in the root directory (above the document root) then it would attempt to rewrite the request to /root/index.php (as opposed to /root/public_html/index.php) which is inaccessible (from rewriting in .htaccess) and does not exist anyway, so would likely result in a 403, 400, etc.

Installing Codeigniter 4 in a subdirectory and keep the domain general URL structure

Current situation:
I already have a Wordpress installation at http://example.com and this site is multilanguage so you can access a web page in English at http://example.com/en/something-here/ and you can access the Spanish version of this webpage at http://example.com/es/algo-aqui/.
What I am trying to do:
I want to install Codeigniter 4 in http://example.com/software/ but I want to keep the general website URL structure, so I need to be able to access the CI4 software through the URL http://example.com/en/software/ and http://example.com/es/software/. Always reading the same CI4 installation mentioned at the beginning of this paragraph.
What I already tried:
I deployed the CI4 files at http://example.com/software/ and modified the .htaccess files of both, the Wordpress site and Code Igniter.
This is my WP .htaccess file on the root directory:
# Disable directory browsing
Options All -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^[a-z]{2}/software(.*)$ /software/index.php$2 [L]
</IfModule>
# BEGIN WordPress
# Las directivas (líneas) entre `BEGIN WordPress` y `END WordPress` se generan dinámicamente
# , y solo se deberían modificar mediante filtros de WordPress.
# Cualquier cambio en las directivas que hay entre esos marcadores se sobreescribirán.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
And this is my .htaccess file on the "software" directory:
# Disable directory browsing
Options All -Indexes
# ----------------------------------------------------------------------
# Rewrite engine
# ----------------------------------------------------------------------
# Turning on the rewrite engine is necessary for the following rules and features.
# FollowSymLinks must be enabled for this to work.
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# If you installed CodeIgniter in a subfolder, you will need to
# change the following line to match the subfolder you need.
# http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
RewriteBase /
# Redirect Trailing Slashes...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Rewrite "www.example.com -> example.com"
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to the front controller, index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /software/index.php/$1
# Ensure Authorization header is passed along
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 index.php
</IfModule>
# Disable server signature start
ServerSignature Off
# Disable server signature end
The error I am getting:
I can access both, the site and the software. The site works well but when I try to access let's say http://example.com/en/software/, I get a 404 error when I access Codeigniter. The error message says: "Controller or its method is not found: App\Controllers\En::software".
This is as if CI is trying to find the controller En (that not exist) and the method software.
Any help will be appreciated.
I have solved the problem after trying for 2 days relentlessly. Here's the steps I actually followed-
First Backup the Codeigniter4 Application by giving the below command as root:
tar --exclude=".git" -czvf zipped_file_name.tar codeigniter4_project_folder/
upload the codeigniter4_project_folder in public_html directory at Shared Hosing and change the following:
Change the base url in app/Config/App.php or .env file in root folder of codeigniter application (here ci4 is the subdomain which will be configured in cpanel later)
app.baseURL = 'http://ci4.yourdomain.com/'
Change the Database Config in app/Config/Database.php or .env file in root folder
database.default.hostname = localhost
database.default.database = your_db_name
database.default.username = your_db_user
database.default.password = your_db_password
database.default.DBDriver = MySQLi
Change .htaccess file in Public Folder
RewriteBase /codeigniter4_project_folder/
Add the Subdomain in Cpanel ci4.yourdomain.com which path will be as follows:
public_html/codeigniter4_project_folder/public
Here public folder will be the last in the path. It is very important.
Hope this may help others struggling with the problem.
In my case I needed to add:
RewriteRule ^(.*)$ index.php?/$1 [L]
in public/.htaccess.

File not found error even if file is present in FTP

I have files present in FTP but when I'm trying to access those files (html files) I'm getting "The requested URL was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."
My .htaccess file code is this and I have tried some of the solutions but none worked. Can you please tell me what's wrong or missing in htaccess file.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /demosite/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /demosite/index.php [L]
</IfModule>
# END WordPress

Error when proxying to blog sub domain from node.js application

I have a nodejs app hosted on heroku, on www.example.com
I then have a wordpress blog, currently on a subdomain - blog.example.com
I have a route setup in express:
(using express-http-proxy)
var proxy = require('express-http-proxy');
app.use('/blog', proxy('blog.example.com', {
forwardPath: function(req, res) {
return require('url').parse(req.url).path;
}
}));
This works, in the sense that I can see the blog "home page" on www.example.com/blog - it's proxying correctly and transparnelty to blog.example.com
However, if I visit any of the blog posts on there, it falls over with a 500 error
[error] [client (ipAddressHere)] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://www.example.com/blog/
I suspect it’s something to do with my htaccess - but can’t quite figure out what?
My htaccess is:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
Removed /blog from my htaccess to make it:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
It now works
Transparent proxying from my node app /blog to wordpress blog!

CodeIgniter deleting index.php with htaccess after normal installation of apache 2.4

I have installed PHP, Mysql and Apache on windows server 2008 R2 as this link provided exactly.
It's working like a charm, but the problem is with my .htaccess to remove index.php.
My .htaccess file includes the following:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /HR/ #Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
I already enabled mod_rewrite in apache. but I'm getting 500 internal server error.
NOTE: when changing AllowOverRide All to None in Document root like here:
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
the 500 internal error disappears but the .htaccess does not work!!! then I should add the index.php for the link to work.
Note: when AllowIverRide All I get this error:
[Tue Feb 19 18:20:10.988018 2013] [core:alert] [pid 3940:tid 844]
[client 127.0.0.1:49513] C:/Apache24/htdocs/HR/.htaccess:
RewriteBase takes one argument, the base URL of the per-directory context
Any help will be Appreciated. TY.
Not to completely change your .htaccess entirely, but here is an example of the one I use that I never have any issues with. This is only the part in regards to modrewrite:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(templates|plugins)
RewriteRule ^(.*)$ index.php/$1 [L]

Resources