简体   繁体   English

我如何解决此HTACCESS以允许WP的子文件夹安装(以及它自己的htaccess modrewrite规则)

[英]How can I fix this HTACCESS to allow Sub Folder Installation of WP (and it's own htaccess modrewrite rules)

I have a application that uses rewrite conditions, and then I added wordpress. 我有一个使用重写条件的应用程序,然后添加了wordpress。 I could not get /blog to rewrite properly. 我无法使/ blog正确重写。

Please see below for both HTACCESS files in root, and /blog (where wordpress is installed). 请参阅下面的根目录中的HTACCESS文件和/ blog(安装了wordpress)。 I need to create a reference in root to allow /blog to work properly (im guessing). 我需要在根目录中创建一个引用,以允许/ blog正常工作(我猜测)。 But how can I do this without breaking my other rewrite rules? 但是,如何在不违反其他重写规则的情况下做到这一点?

/.htaccess /.htaccess

RewriteEngine on

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

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?sn=$1 [QSA,L]
#RewriteRule ^([a-zA-Z0-9/%-]+)$ index.php?sn=$1 [QSA]

Then in wordpress my wordpres install folder, i am simply doing: /blog/.htaccess 然后在wordpress我的wordpres安装文件夹中,我只是在做:/blog/.htaccess

#for blog directory only
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

... and all other rw conditions needed for caching, etc ...以及缓存等所需的所有其他读写条件

The reason the error was persistent with this dual HTACCESS setup was because the /blog/.htaccess file was missing an additional line: 该双重HTACCESS设置导致错误持续存在的原因是/blog/.htaccess文件缺少另一行:

RewriteRule . /blog/index.php [L]

Once added, it operated fine. 添加后,它运行良好。 No chances needed to go into the root htaccess to reference the /blog/ rewrite conditions. 无需进入htaccess根目录来引用/ blog /重写条件。 This allows for a wordpress install in a blog folder, and above references dual HTACESS rules 这允许在Blog文件夹中安装wordpress,并且上面引用了双重HTACESS规则

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM