簡體   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