找不到 apache2 重写页面
apache2 rewrite page not found
我刚刚完成了 apache 的设置。
设置如下:
我的虚拟主机:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName system.local
ServerAlias www.system.local
DocumentRoot /var/www/system
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
我的主机文件是:
127.0.1.1 system.local
我还使用 a2enmod 来启用 mod_rewrite。
当我打开我的应用程序并转到 /Admins/index 时,我发现找不到页面。
有谁知道我可能遗漏了什么?
如果您使用的是 .htaccess 文件。您需要使用 AllowOverride All
允许在您的 Web 目录中使用 .htaccess 文件。为此,您的代码应如下所示。
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName learningbank.local
ServerAlias www.learningbank.local
DocumentRoot /var/www/system_learningbank
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/system_learningbank>
AllowOverride All
</Directory>
</VirtualHost>
另外,更改配置时不要忘记重新启动 apache。
我刚刚完成了 apache 的设置。
设置如下:
我的虚拟主机:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName system.local
ServerAlias www.system.local
DocumentRoot /var/www/system
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
我的主机文件是:
127.0.1.1 system.local
我还使用 a2enmod 来启用 mod_rewrite。
当我打开我的应用程序并转到 /Admins/index 时,我发现找不到页面。
有谁知道我可能遗漏了什么?
如果您使用的是 .htaccess 文件。您需要使用 AllowOverride All
允许在您的 Web 目录中使用 .htaccess 文件。为此,您的代码应如下所示。
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName learningbank.local
ServerAlias www.learningbank.local
DocumentRoot /var/www/system_learningbank
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/system_learningbank>
AllowOverride All
</Directory>
</VirtualHost>
另外,更改配置时不要忘记重新启动 apache。