public folder on codeigniter and clean URL - codeigniter

with the idea of ​​protecting / limit access to folders codeigniter, I created a public folder.
The main idea is that users can only access the public folder
<VirtualHost *:80>
     DocumentRoot "www / codeigniter / public"
     <Directory "www/codeigniter">
     Options Indexes FollowSymLinks Includes ExecCGI
     AllowOverride All
     Require all Granted
     </ Directory>
</ VirtualHost>
This works, but when I try to clean the url, so it does not appears the index.php generates an errror 503.
the .htaccess file I created is as follows
<IfModule mod_rewrite.c>
Options + FollowSymLinks
RewriteEngine On
RewriteCond% {REQUEST_FILENAME}!-D
RewriteCond% {REQUEST_FILENAME}!-F
RewriteRule ^ (. *) $ Index.php? / $ 1 [L]
</ IfModule>
What am I doing wrong or that I left to do?
pardon the English, GoogleTranslate

Your .htaccess has some strange spacing issues that break the site when I replicate them on one of my codeigniter sites. I would try with these changes.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

Related

Getting 404 by using Laravel routes - rewrite not working

I'm using Laravel-5 framework and created the following route in the routes/web.php:
Route::get('/test', function () {
return view('test');
});
After navigating to myapp.dev/test I get an Error 404:
Object not found! The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
Navigating to myapp.dev/index.php/test works fine. So, looks like rewrite_mod is not working.
I'm using XAMP/Apache and rewrite_module is enabled in httpd.conf:
LoadModule rewrite_module modules/mod_rewrite.so
My larvavel's public folder contains a .htaccess file with following content:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
#DirectoryIndex index.php
# 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>
The httpd-vhost configuration looks like the following:
<VirtualHost *:80>
ServerAdmin my#mail.com
DocumentRoot "s:/_dev/myapp/public"
ServerName myapp.dev
<Directory "s:/_dev/myapp/public">
Allow from all
Require all granted
#Options Indexes
</Directory>
ErrorLog "logs/myapp.dev-error.log"
CustomLog "logs/myapp.dev-access.log" common
</VirtualHost>
Any ideas what I missed?
Thanks
I can not see any issues with our code however it could be a browser issue.
Have a look at this article which goes through the changes to browsers that cause issues with .dev domains.
https://medium.engineering/use-a-dev-domain-not-anymore-95219778e6fd

Laravel - set /public as root on LAMP stack

I'm trying to deploy a Laravel App on a LAMP stack although I am having trouble setting the document root as /public. I've looked at several answers on here already for similar problems but am yet to find my problem or a solution. I ideally I want to do it through the Apache web server and not modify any Laravel files.
I copied the default .conf file a change it to the following using sudo nano /etc/apache2/sites-available/subdomain.website.com.conf
<VirtualHost *:80>
ServerAdmin email#gmail.com
ServerName subdomain.website.com
ServerAlias www.subdomain.website.com
DocumentRoot /var/www/subdomain.website.com/public_html/public
<Directory /var/www/subdomain.website.com/public_html/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
</IfModule>
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.subdomain.website.com [OR]
RewriteCond %{SERVER_NAME} =subdomain.website.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
After the I ran the following commands in this order.
sudo a2ensite subdomain.website.com.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
sudo service apache2 restart
I cleared cookies, did a hard refresh and it hasn't worked. I still have to go to https://subdomain.website.com/public to view the website. Is there anything I have missed or anything I can do find out what the problem may be?
The .htaccess file in the /public folder contains the following
<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>
This virtualhost is for http:// (Port 80). You have a rewrite rule that redirects to https:// as soon as it hits this virtualhost.
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.subdomain.website.com [OR]
RewriteCond %{SERVER_NAME} =subdomain.website.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
Therefore, you need to apply your changes to the other virtualhost that is serving this domain from https:// (Port 443).

laravel 5 error 500 fresh install

Hello so i got back to laravel recently and want to put on my webserver but i get error 500 from a fresh installed laravel. though i havent done any modifying the code in the framework would be sweet if anyone has an idea whats going on in the changes to laravel from those settings i provide
error 500 and no logs in apache nor laravel
thanks in advance
htaccess file.
<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}]
conf file
ServerName domain.com
DocumentRoot /var/www/laravel/public/
<Directory /var/www/laravel/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
If you're using Linux os,you'll need to do the following
cd to_the_root_of_project - i.e. cd /var/www/html/LaravelProject
sudo chmod guo+w -R storage/

Laravel status not found, missing route

I'm trying to install Laravel on Wamp server and I'm getting this error:
{"status":"Not Found","error":true,"error_code":"missing_route","message":"Route not found.","data":[]}
Been searching for a while now and can't figure out what it is. I checked and triple checked if I added corectly my project in hosts file, if virtual host is set properly, also if rewrite module is activated and if .htaccess file in the public folder is as it should.
Hosts File:
127.0.0.1 app.my-site.com
Vhosts
<VirtualHost *:80>
ServerAdmin webmaster#my-site.com
DocumentRoot "C:/wamp/www/my-site/public"
ServerName app.my-site.com
<Directory "C:/wamp/www/my-site/public">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog "logs/my-site-error.log"
CustomLog "logs/my-site-access.log" common
</VirtualHost>
.htaccess in public folder
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
Options +FollowSymLinks
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>
Can anybody suggest what could be wrong?

Codeigniter App with Symlink -Remove index.php from URL

I went through many resources here and elsewhere in net but couldnt seem to make it work.
I have codeigniter app in home directory. Sym link craeated in /var/www/html.
The below link works fine.
http://mydomain.net/dms/index.php/welcome
However without index.php ,I want the following link to work
http://mydomain.net/dms/welcome
Code igniter 2.1.1 directory:
dms
application
system
index.php
.htaccess
Config.php
$config['index_page'] = "";
$config['uri_protocol'] = "AUTO";
routes.php
$route['default_controller'] = "welcome";
Config file httpd.conf
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
Alias /dms/ "/var/www/html/dms/"
<Directory "/var/www/html/dms">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
sym links
ls -l /var/www/html
dms -> /home/user1/dms
.htaccess file :
RewriteEngine On
# enable symbolic links
Options +FollowSymLinks
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+) index.php [L]
I tried keeping .htaccess file in CI folder folder /home/user1/dms and later in /var/www/html
Both didnt work.
I am getting error (in http error log)
"File does not exist: /var/www/html/dms/welcome"
Please help.
I use this .htaccess and it works for me, try:
<IfModule mod_rewrite.c>
# Make sure directory listing is disabled
Options +FollowSymLinks -Indexes
# disable the Apache MultiViews directive if it is enabled on the server. It plays havoc with URL rewriting
Options -MultiViews
RewriteEngine on
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
</IfModule>

Resources