Debian 11和Apache 2- .htaccess无法使用

qrjkbowd  于 2022-11-16  发布在  Apache
关注(0)|答案(1)|浏览(158)

我有一个问题。我有一个VPS与Debian 11和Webmin,我想托管我的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]

我的域.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

ocebsuys

ocebsuys1#

你确定抓到他了吗

检查是否正确

cat /etc/apache2/mods-available/rewrite.load

"用sudo激活他"

sudo a2enmod rewrite

然后重新启动apache2

sudo service apache2 restart

相关问题