Apache ignores .htaccess file - apache

I have a debian apache server. For some reason apache ignores my .htacces file. Any ideas why this is happening?
Here is my /etc/apache2/sites-available/default file
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride none
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Here is my .htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
I have also enabled apache rewrite mod.

Panama Jack thank you so much,
Based on your answer i find out the solution i was looking for. I added at the top of my .htaccess this line
Options +FollowSymLinks -MultiViews
that i found here
RewriteEngine On .htaccess not working
Thanks so much again!

Related

laravel5.1 laravel in subfolder (routes not working) results in 404 apache error

My current setup on my production server is like the following:
there are two folders in
var/www/html
These two folders are named:
xyz
doge
Now I would like to place all requests to IP/doge into the doge folder.
This seems to work, but only the index page is working. Using the already created routes like for example:
ip/doge/login
will result in a 404 error page of apache.
Here's my apache config:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/xyz/public
Alias "/doge" "/var/www/html/doge/public"
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/html/xyz/public/>
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Any idea where's my fault? I haven't changed the .htaccess in the public folder of each laravel project. This .htaccess looks like:
<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>

Subdomains Always Redirect To Main Domain - Apache2 VirtualHosts & Debain

I want to set up a main site, and a sub-domain for development, using apache2 VirtualHosts. This is what my site.conf virtual host file looks like:
<VirtualHost *:80>
ServerName dev.mysite.com
DocumentRoot /var/www/site/subdomain
<Directory /var/www/site/subdomain >
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel debug
CustomLog ${APACHE_LOG_DIR}/sub.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName www.mysite.com
ServerAlias mysite.com
DocumentRoot /var/www/site/main
<Directory /var/www/site/main >
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The problem is that every time I visit dev.mysite.com, I just get mysite.com.
There's no htaccess for the main site, and the .htaccess for the sub-domain looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I've tried all the other solutions I could find (using literal IPs, re-ordering things, using ports instead of named hosts)... I'm totally stuck now. The site is enabled of course. Anyone got any ideas?
Wordpress Was The Problem
Or rather, me not knowing that I had to configure the Wordpress site url to be the subdomain, otherwise it would just redirect to the domain given...
So the solution: open the wp_options table and edit the site_url to include the subdomain.

Apache ErrorDocument issue

i am trying to make my own 403 page but my apache doesn work correct.
I use
ErrorDocument 403
but it shows the same. This is my .htaccess:
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
Here is my host settings:
<VirtualHost 127.0.1.15:80>
ServerAdmin webmaster#localhost
ServerName turik.loc
ServerAlias *.turik.loc
DocumentRoot /home/golars/proj/turik/
<Directory />
Options FollowSymLinks MultiViews
AllowOverride All
</Directory>
<Directory /home/golars/proj/turik/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Order allow,deny
Allow from all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/t4base_error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
To 403 error i am going to turik.loc/img/hotels/ -where i dont have permissions to read&write. I would be graceful for a help.

htaccess vhost codeigniter index.php

I have read a lot of topic with the same problem but i do not find the solution... please help me. I have a lamp into ubuntu server. My document root is /home/utente/ into this dir I have another dir (turni) with a codeigniter web app. The web app works fine with the "index.php" into the url, but I want to eliminate it. I have this configuration:
config.php into codeigniter:
$config['index_page'] = '';
.htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
/etc/apache2/sites-available/default:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /home/utente
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/utente/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
When i open a link of the web app with without eh "index.php" into the url, the server o me this error: The requested URL /turni/auth/login was not found on this server.
Why??? If i put the index.php like /turni/index.php/auth/login all works fine....
Thanks for help and sorry for my english :D
Add .htaccess to your server root directory and change the rewrite base to
RewriteBase /turni
assuming your codeigniter is present in /var/www/turni

Redirect non-existent dynamic virtual host folders with Apache

Is it possible to redirect to a certain URL if the directory for the virtual host doesn't exist? I have a VirtualHost setup below that lets me host a domain just by creating the folder, and pointing DNS to my server.
Here is my configuration for the VirtualHost
<VirtualHost *:80>
ServerAdmin webmaster#localhost
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*) http://%1/ [R=301,L]
VirtualDocumentRoot /var/www/%0
<Directory /var/www/%0>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
You can manage it using rewriting rules.
Just after you rewriting rule to skip www :
RewriteCond %{HTTP_HOST} ^(.*)$
RewriteCond /var/www/%1 !-d
# I think just /var/www/%{HTTP_HOST} works :|
RewriteRule .* http://example.com/nonexistant.php/$0 [L,R]