Apache (httpd) 伪静态设置

Apache 2.2

DocumentRoot "/var/www/example.com/public"
<Directory "/var/www/example.com/public">
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</Directory>

Apache 2.4

Apache 文档

apache 2.4 的 rewrite 需要多配置一个 RewriteBase

如果项目部署在域名根目录, 则在 RewriteEngine on 后面添加一行

DocumentRoot "/var/www/example.com/public"
<Directory "/var/www/example.com/public">
    RewriteEngine On
    RewriteBase "/"
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</Directory>

原文

apache2.4和2.2的伪静态是不是不一样啊?

最后更新于 2020-05-23
使用 Hugo 构建
主题 StackJimmy 设计