2015-05-29 96 views
0

我想從Wordpress中特定(已使用的URL)上的特定文件夾加載內容(index.html)。使用.htaccess加載特定Wordpress URL(類別URL)的文件夾

這裏的.htaccess文件(默認):

# 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 

我這個重寫規則的一些變化的嘗試:

RewriteRule ^/category/funny-posts/ /funny-images/ [L] 

這麼好笑圖像是我所在服務器上的目錄我安裝了WP。他們都在根文件夾中。

當我輸入www.site.com/category/funny-posts/時,如何從/ funny-images /加載index.html?

回答

1

如果index.html文件沒有顯示(並且所需的URI正在傳遞給WP),這可能是因爲您將規則放在最後。試着把它放在RewriteEngine On之後。哦,我不認爲你需要那個RewriteBase。此外,您不需要在新規則中的前導斜槓,即category之前。

你的文件現在應該是這樣的:

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

這實際上工作! :) 我現在需要做的唯一事情就是修復相對路徑,因爲在index.html中,而不是獲取/js/example.js,它會嘗試獲取/funny-posts/js/example.js – user1410644

+0

很高興沒有。您只需要在對JS文件的引用中使用前導斜槓。或者,使用HTML''標籤。 –