【问题标题】:How would I update these rules so both can run in .htaccess?我将如何更新这些规则以便两者都可以在 .htaccess 中运行?
【发布时间】:2020-09-20 20:46:02
【问题描述】:

我需要将这两者合并到我的 .htaccess 文件夹中。如果第一条运行,WordPress 工作正常,但我的论坛没有。如果底部运行,则相反。我做了一些研究,发现这是因为我在代码中有多个 RewriteBase。不过,我需要一些帮助才能将它们合并在一起。谢谢。

<IfModule mod_setenvif.c>
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
</IfModule>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /forum/api/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
</IfModule>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /forum/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) /forum/404error.php [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /forum/index.php [L]
</IfModule>

【问题讨论】:

    标签: php apache .htaccess mod-rewrite


    【解决方案1】:

    我想我明白了。这至少对我有用。

    <IfModule mod_setenvif.c>
    SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
    </IfModule>
    <IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^forum/api/.* index.php [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^forum/\.(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) /forum/404error.php [L,NC]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^forum/. /forum/index.php [L]
    </IfModule>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-17
      • 2017-11-07
      • 1970-01-01
      • 2021-02-22
      相关资源
      最近更新 更多