小编Cha*_*had的帖子

.htaccess RewriteRule 不起作用

我有一个使用 WAMP 的 Windows 环境,效果很好。我刚刚设置我的 Ubuntu 桌面开发环境,这个特定的 mod_rewrite 不起作用。

这是非常基本的,但是如果我去,我会从 apache
example.local/files/a-real-file.pdf得到一个。404 not found如果我转到
example.local/files.php/a-real-file.pdf该文件,就会按预期显示。如果我去,
example.local/files.php/non-existing-file.who.cares我会var_dump($thelink)从我的逻辑中得到预期的结果files.php

.htaccess在我的网络根目录中

RewriteEngine On
RewriteRule ^files/(.*)$ files.php/$1
Run Code Online (Sandbox Code Playgroud)

我的 apache 虚拟主机配置

<VirtualHost *:80>
    ServerName reqapp.localhost
    DocumentRoot /var/www/html/aaApp/public_html
    <Directory /var/www/html/aaApp/public_html/>
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

为了更好地衡量,“localhost”conf

<VirtualHost *:80>
    ServerName localhost
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

以及“适用”部分apache2.conf

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all …
Run Code Online (Sandbox Code Playgroud)

mod-rewrite .htaccess apache-2.4

5
推荐指数
1
解决办法
6046
查看次数

标签 统计

.htaccess ×1

apache-2.4 ×1

mod-rewrite ×1