我无法配置Apache和我项目的.htaccess文件。我将它存储在/ var / www / html中的子文件夹中,并通过Apache对其进行别名处理。我还在我的.htaccess文件中添加了RewriteBase。访问别名(server.ip / blog)列出了公共目录,但我尝试访问的所有内容都返回404错误。有什么想法吗?
htaccess的:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /index.php [L]
RewriteBase /blog/
Apache站点.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 *:80>
ServerAdmin mymail@gmail.com
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>
提前致谢!
答案 0 :(得分:2)
首先,从new RecipientsGenerator();
中删除斜杠,然后向上移动/index.php
:
您的RewriteBase
文件应保存在.htaccess
目录中,并且应包含以下内容:
blog
RewriteEngine on
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
不需要在该文件中,因为配置已经设置了它。
如果您使用的是Apache 2.4(而非2.2),您的虚拟主机Options +FollowSymlinks
应如下所示:
<directory...>
此外,这不需要在<Directory "/var/www/html/exoblog/public">
Require all granted
AllowOverride All
Options Indexes Multiviews FollowSymLinks
</Directory>
文件中重复。