Reputation: 61
I am having trouble configuring Apache and my project's .htaccess file. I am storing it in a subfolder in /var/www/html, and aliasing it via Apache. I have also added RewriteBase to my .htaccess file. Accessing to the alias (server.ip/blog) lists the public directory, but everything I try to access returns a 404 error. Any ideas?
.htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /index.php [L]
RewriteBase /blog/
Apache site .conf:
Alias /blog/ "/var/www/html/exoblog/public"
<Directory "/var/www/html/exoblog/public/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
VirtualHost:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/var/www/html/exoblog/public"
ServerName eneko.dev
ServerAlias www.eneko.dev
ErrorLog "/var/log/apache2/exob.log"
CustomLog "/var/log/apache2/exob.log" common
<Directory "/var/www/html/exoblog/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Thanks in advance!
Upvotes: 2
Views: 4317
Reputation: 9007
Firstly, remove the slash from /index.php
, and move your RewriteBase
up:
Your .htaccess
file should be saved in your blog
directory and should contain the following:
RewriteEngine on
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Options +FollowSymlinks
does not need to be in that file as the configuration already has it set up.
If you are using Apache 2.4 (as opposed to 2.2), your virtual host <directory...>
should look like this:
<Directory "/var/www/html/exoblog/public">
Require all granted
AllowOverride All
Options Indexes Multiviews FollowSymLinks
</Directory>
Also, this does not need to be duplicated in the conf
file.
Upvotes: 2