【问题标题】:cannot access url string something missing on my code?无法访问我的代码中缺少的 url 字符串?
【发布时间】:2022-10-24 09:22:42
【问题描述】:

我有一个 apache 问题,给我一个“未找到”错误。

设想:

我有一个形式的 url --> 10.17.10.19/webapps/api/index.php?url=auth

我想重写表单中的url --> 10.17.10.19/webapps/api/auth

我正在使用 Ubuntu 20.04 apache2

虚拟主机:

      <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/
<Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Require all granted
            Order allow,deny
            allow from all
</Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

访问:

RewriteEngine On
Options All -Indexes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

apache.conf

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        Options Indexes
# FollowSymLinks
#       AllowOverride None
        Require all granted
</Directory>

#<Directory /srv/>
#       Options Indexes FollowSymLinks
#       AllowOverride None
#       Require all granted
#</Directory>

请帮我纠正条件以识别参数

【问题讨论】:

  • 我已经启用 aen2mod 重写但仍然无法正常工作
  • 该分布式配置文件(“.htaccess”)位于何处?
  • /var/www/html/webapps/api/.htaccess
  • 为什么DocumentRoot /var/www/html/&lt;Directory /var/www/&gt; 之间存在差异?
  • 登陆页面和目录的文档根是我们设置规则的时候吗?两种不同的东西

标签: apache .htaccess ubuntu url vhosts


【解决方案1】:

我找到了答案 我需要启用标题,以便 htaccess 可以工作

ae2enmod header

https://httpd.apache.org/docs/2.4/mod/

【讨论】:

  • 您能否edit 详细说明您为解决问题所做的具体工作?这可以帮助将来遇到同样问题的人看到这篇文章。
  • 请不要添加“谢谢”作为答案。反而,accept the answer你觉得最有帮助的。 - From Review
  • 抱歉,我编辑了答案
猜你喜欢
  • 1970-01-01
  • 2019-07-12
  • 2016-11-21
  • 1970-01-01
  • 1970-01-01
  • 2021-01-16
  • 2020-01-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多