LAMP shows index.php in var/www/html instead of project - php

i have installed LAMP on Ubuntu-16.04.
Now in my var/www/html I have created a file called index.php which shows info about my PHP.
Also i have a folder called FMS which is my Codeigniter Project Folder.
When I fire localhost/FMS it shows the url to be : localhost/FMS/secure/login
but displays the index.php page
is this issue of codeigniter/.htaccess ??
Or is there anything wrong with my server configuration ?
.htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase /FMS
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
<ifModule mod_headers.c>
Header add Access-Control-Allow-Origin "*"
</ifModule>
<IfModule !mod_rewrite.c>
apache2.conf
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

Related

Laravel vhosts setup in xampp is working for only first page

I am working with laravel project. It works fine with php artisan. When I setup vhosts it's working only index page(Welcome page) but when I click on login,signup or any other pages it's not working. It shows page not found.
My httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/my_laravel/public"
ServerName laravel.dev
ServerAlias laravel.dev
ErrorLog "logs/laravel.log"
CustomLog "logs/custom.laravel.log" combined
<Directory "C:/xampp/htdocs/my_laravel/public">
AllowOverride All
Options Indexes FollowSymLinks
Require all granted
</Directory>
</VirtualHost>
And my hosts file
127.0.0.1 laravel.dev
.htaccess file inside 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]
</IfModule>
You have to define URL rewrite in the public/.htaccess File.
Check if you have the correct settings there.
The Laravel default File looks like this:
<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]
Just backup your .htaccess and try to copy paste this to your htaccess file and check if it works. If you use Laravels Authorization you also have to add this
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
Maybe you also have to turn on the Modules mod_rewrite.c and mod_negotiation.c if they arent already.
You can do this by search and uncomment the line for the desired module in apache\conf\httpd.conf
If you want to customize your .htaccess for what ever reason there are many ressources available on the web.

NotFoundHttpException when using alias on wamp

I create BlogTest laravel 5.6 project on local machine. I have installed wamp, and create alias like http://localhost/blogtest/. Also crete .htaccess file in root of project and in public folder.
When I try to open any route even http://localhost/blogtest/ I get NotFoundHttpException error! But if I try http://localhost/blogtest/public/ then it works!
What is problem here?
This is alias config files and .htaccess files.
blogtest.config:
Alias /blogtest "e:/test.web/Blog.Test/"
<Directory "e:/test.web/Blog.Test/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
<ifDefine APACHE24>
Require local
</ifDefine>
<ifDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from localhost ::1 127.0.0.1
</ifDefine>
</Directory>
Root .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blogtest/
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Public folder .htaccess file:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /blogtest/
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Did anyone have similar problem?

WordPress As A Symfony (Symfony3) Subdirectory

I am running a Symfony app on DigitalOcean. I have setup the entire site and created VirtualHosts. I need to run WordPress as a subdirectory (/blog). From what I know Symfony tends to ignore subdirectories in /web so I created /web/blog and installed WordPress in it.
<VirtualHost *:80>
DocumentRoot /var/www/html/site.com/web
<Directory /var/www/html/site.com/web>
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</Directory>
ErrorLog /var/log/apache2/symfony_error.log
CustomLog /var/log/apache2/symfony_access.log combined
</VirtualHost>
On localhost installations without VirtualHost this runs perfectly.
But on the live server, lets say at 21.21.21.21 I have Symfony running and 21.21.21.21/blog should open blog but it doesn't, instead goes to a Symfony 404. Whereas 21.21.21.21/blog/index.php runs the blog (WordPress).
The WordPress .htaccess which lives in /web/blog is as follows:
Options -Indexes
DirectoryIndex index.php
# 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
I have tried tinkering with this with some answers on the web, nothing changes.
Update your vhost so that you exclude your /blog directory from symphony rules. And you will also need to change to AllowOverride All since you are using .htaccess in /blog.
<VirtualHost *:80>
DocumentRoot /var/www/html/site.com/web
<Directory /var/www/html/site.com/web>
AllowOverride All
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/blog(/.+)? [NC]
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</Directory>
ErrorLog /var/log/apache2/symfony_error.log
CustomLog /var/log/apache2/symfony_access.log combined
</VirtualHost>
Be sure to restart apache after changes.
WordPress .htaccess Changes:
Options -Indexes
DirectoryIndex index.php
# 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

.htaccess not working with Laravel

I'm using Laravel 5.1 with a PuPHPet VM using Apache (so not Homestead).
I've got the default .htaccess in my public dir;
<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 in to the apache2.conf;
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all granted
</FilesMatch>
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
And I've restarted apache2;
sudo service apache2 restart
But I still get a not found on;
http://192.168.56.131/auth/register
But not on;
http://192.168.56.131/public/auth/register
So I'm not sure what to try now. Part of it must work because the index.php is no longer required
* UPDATE *
This is working;
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
But this does not;
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
It just doesn't like the whole "public" thing.
This is an updated partial of my apache2.conf file;
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
So frustrating! I don't understand what I am missing here.
Your Apache config should go within the vhost config file, not htaccess.
PuPHPet uses php-fpm, mod_php support was dropped several months ago.
Try
RewriteEngine On
RewriteRule ^(.*)$ /public/$1 [L]

Laravel 5 shows php file content in browser (doesn't render html)

Laravel 5 site doesn't render html, rather it shows php file content in browser. I tried various apache configurations and changes in htaccess but no luck. Not sure where this is going wrong.
Here is the .htaccess file
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
DirectoryIndex index.php
RewriteEngine On
# Redirect Trailing Slashes...
#RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ public/$1 [L]
# RewriteRule ^ index.php [L]
</IfModule>
and here is the apache conf file:
<VirtualHost *:80>
DocumentRoot /var/www/laravelapp/public
ServerName laravelapp.dev
ServerAlias laravelapp.dev
<Directory "/var/www/laravelapp/public">
AllowOverride all
Allow from all
</Directory>
</VirtualHost>

Categories