laravel php 5.4 running on apache server - php

i get a 403 when i browse to the root directory of my laravel project. When i go to root/public i do get a you have arrived message from the framework. But this isnt what is supposed to be right? How do i make my project so that when i go to the root i actually get into /public?
i have tried the following:
This is how my htaccess file looks like in in the root:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

You need to set DocumentRoot properly in your Apache configuration. This is separate from the .htaccess and it should point at the public directory.

If you can't configure apache directories, for production environment, put 2 .htaccess files.
The 1. is in the root folder:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
The 2. is in the /public folder:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

Related

Apache or PHP not specifying the assets folder correctly

I have this site written in PHP using Phalcon but for some reason when I switch from WAMP to XAMPP it doesn't use the public folder for assets like css/js/fonts/etc but uses the root folder instead? I've tried messing with the .htaccess files but no luck. Here's what I have:
.htaccess file in root directory:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
.htaccess file in root/public
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?s).*)$ index.php?_url=/$1 [QSA,L]
</IfModule>
Is there any way to fix it to make it get the assets from the public folder instead of the root folder?

How to configure .htaccess for subdirectory

I have a WordPress site hosted on AWS and I am having a hard time to configure mod_rewrite to work correctly.
Folder structure
/root
|_ staging/
|_ live/
The .htaccess is the WordPress default
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Main Problem
I can access /staging/index.php/api which I used to access it without subdirectories like this ---.com/api.
When I try /staging/api it shows File not found.
I tried to change the .htaccess to different thing but none of them was successful.
There are no .htaccess file in the root directory.
Some help would be appreciated =)
Thanks in advance.
Try this code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /staging
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /staging/index.php [L]
</IfModule>
Note: The AllowOverride should be set to All in server configuration.
You can find the reference from here.
How to Set AllowOverride all

Cakephp 3 .htaccess File Configuration

I've spent much time to find out this trouble, that my cakephp running on my localhost server, but when I move my cakephp to hosting server, cakephp just shows blank page, anyone have codes .htaccess in root folder, cakephp folder, and another that need for my cakephp running on server ?
for your information, my cakephp version is cakephp 3
I've tried with this code
in root .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
in my folder cakephp .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /my_app_name
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
in my webroot folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
for many tutorial that I've read, they said we have set 3 .htaccess file, is there any wrong code in my .htaccess file so I cannot access my website?
[CASE CLOSED]
The solutions is just make sure your php already enable intl in your hosting / shared server

How to install laravel app in subfolder of shared host?

I install laravel app in root of my shared host "public_html now I want to install Russian version of this app in ru/ subfolder but when I go to example.com/ru I got 404 Page not found error. I use apache web server my .htaccess file in root folder contain these code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
how should i change this configuration?
Thanks.
You will do it in the same way you installed it in the root directory. I will tell you how I installed it on my shared hosting account, both main and sub domains. After I uploaded all my project to the subfolder, and your will be example.com/ru, do the following:
In your public folder there is your .htaccess file. since you are basically making this a subdomain, it will need to be in the root of that subdomain, so transfer the .htaccess from public folder to the root of ru folder.
Open the .htaccess and change/add the following:
DirectoryIndex public/index.php
and in the RewriteRule change it to this:
public/index.php
And just to be clear, your .htaccess should be like this at the end after your changes:
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 ^(.*)/$ /$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>
Create a .htaccess file in a root folder and paste the code and save it.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]
RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/$1
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php

How can i deploy a PHP web application in subdomain using .htaccess permission

I have deployed a PHP web application on my host (root of my host) now i want to install a web analytic php web application in a folder called "stat" (in the root of my host as a sub domain) but ".htaccess" file in the root of first PHP application does not allow to access "stat" folder how can i config ".htaccess" file to allow map stat.mydomain.com to "stat" folder.
This is ".htaccess" file located in the root of my host:
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L]
</IfModule>
I wish i can describe my problem clearly. please help me as soon as possible.
Thanks in advance.
First thing first I hope you have a VirtualHost entry in your httpd.conf for subdomain stat.mydomain.com as commented by faa.
Once you have that working change your $DOCUMENT_ROOT/.htaccess with this:
DirectoryIndex index.php
Options +FollowSymLinks -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php?qa-rewrite=$0 [L,QSA]
</IfModule>

Categories