繁体   English   中英

Wordpress .htaccess防止子文件夹重写其自己的网址

[英]Wordpress .htaccess preventing sub folder from rewriting its own urls

因此,我已经寻找了一段时间,似乎找不到我正在寻找的特定解决方案。 我看过许多文章,展示了如何通过Wordpress重写解决问题,但都没有解决我的问题。

我当前在/根目录中安装了Wordpress。 .htaccess看起来像这样。

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^manager - [L,NC] <-- I added this from other examples.
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

因此,据我所知,这告诉wordpress,嘿,您将处理所有内容的所有网址。 永远。 认真。 永远无处不在:P

所以问题出在我有一个子目录site.com/manager时

在这里,我想构建一个类似的URL捕获方法来管理用户看到/访问/等的内容。 我添加到根.htaccess文件中的行(根据我的阅读)应该是告诉wordpress的,嘿,请不要触摸我该死的/ manager文件夹。

WordPress是无法听的偷偷摸摸的贪婪的保姆。 生病去测试我的site.com/manager/test(抓取测试并从sql中获取信息),然后wordpress接管并把我扔到wordpress 404页面。

我在/ manager中的.htaccess文件如下所示,我想我也需要在这里做一些重写工作,但现在只是为了防止wordpress过于疲劳:)。

DirectoryIndex index.php
<FilesMatch "\.(php|inc)$">
Order allow,deny
deny from all
</FilesMatch>
<FilesMatch "(index.php|logout.php)$">
Order allow,deny
allow from all
</FilesMatch>

任何想法,想法,评论,关注将不胜感激。

谢谢。

因此,在深入研究并进一步研究之后,我找到了解决方法。 不确定这是最佳解决方案,但是否能正常工作。

根(/).htaccess

#Manager - A customer content manager
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/manager/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>
#end Manager

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

这似乎超过了需要的WordPress。

经理(/经理).htaccess

DirectoryIndex index.php
<FilesMatch "\.(php|inc)$">
Order allow,deny
deny from all
</FilesMatch>
<FilesMatch "(index.php|logout.php|install.php)$">
Order allow,deny
allow from all
</FilesMatch>

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

顶部不是必需的,但是我为文件保护/安全性添加了它。

摘要:

我使用%{REQUEST_URI}来有选择地删除一个子文件夹,并将其应用于更多子文件夹,我将添加另一个

RewriteCond %{REQUEST_URI} ^/manager/(.*)$ [OR]

然后,我将信息输入子目录的.htaccess文件中以进行url重写。 从这里,我可以操纵URL并将其转换为Array列表,以进行进一步的排序和数据库调用。

暂无
暂无

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

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