gpt4 book ai didi

wordpress - 合并 2 个 .htaccess 文件

转载 作者:行者123 更新时间:2023-12-02 11:28:01 24 4
gpt4 key购买 nike

我有 2 个 .htaccess 文件需要合并在一起。一个是由 wordpress 生成的,另一个是站点现有的 .htaccess 文件。这2个文件如下:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mywebsite\.com$
RewriteRule ^(.*)$ http://www.mywebsite.com/$1 [R=301]

RewriteRule ^postreview/$ /viewreview.php [NC,PT,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^.*$ ./template2.php


<IfModule mod_security.c>
# Turn off mod_security filtering.
SecFilterEngine Off

# The below probably isn't needed,
# but better safe than sorry.
SecFilterScanPOST Off
</IfModule>

php_flag session.use_trans_sid off

wordpress 生成的第二个文件:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /projectcars/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /projectcars/index.php [L]
</IfModule>

我尝试了多种方法来组合它们,但要么收到重定向错误,要么收到内部服务器错误。

最佳答案

这是我的修复:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.domain.com [NC]
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

RewriteBase /

RewriteRule ^postreview(\/?)$ /viewreview.php [QSA,NC,PT,L]

RewriteRule ^projectcars/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^projectcars/(.*)$ /projectcars/index.php [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) template2.php [NC,L]

<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>

php_flag session.use_trans_sid off

关于wordpress - 合并 2 个 .htaccess 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7469110/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com