[英]Debian 11 and Apache2 - .htaccess not working
我有个问题。 我有一个带有 Debian 11 和 Webmin 的 VPS,我想托管我的 Laravel 项目,但我需要将所有请求重定向到public/index.php
文件但是......我的 .htaccess 没有工作。
我的 .htaccess 文件
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ public/index.php [L,QSA]
</IfModule>
我也试过
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ public/index.php [L,QSA]
我的 domain.conf 文件
<VirtualHost *:80>
ServerAdmin admin@api.domain.pl
ServerName api.domain.pl
ServerAlias www.api.domain.pl
DocumentRoot /var/www/api.domain.pl/public_html
<Directory /var/www/api.domain.pl/public_html>
Options Indexes FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.api.domain.pl [OR]
RewriteCond %{SERVER_NAME} =api.domain.pl
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
我的 apache2.conf 文件
<Directory /var/www>
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory
我用过命令
a2enmod rewrite
service apache2 restart
service apache2 --full-restart
Apache2 版本:2.4.54 PHP 版本:8.1.8
你确定你有他?
检查您是否正确:
cat /etc/apache2/mods-available/rewrite.load
用 sudo 激活他:
sudo a2enmod rewrite
然后重启apache2
sudo service apache2 restart
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.