簡體   English   中英

在root上安裝CodeIgniter,在子目錄中安裝WordPress

[英]Installing CodeIgniter on root and WordPress in sub-directory

我想創建一個網站,主頁將從CodeIgniter提供。 我將在/ blog /子目錄中使用Wordpress來托管博客。 而已! 我什么都不想要。 只是為了確保:

example.com/somepage/調用CI控制器,其中example.com/blog/some-post/由Wordpress處理。

我不需要CI和WP之間的任何集成或交互。

是否可以這樣安裝? 如果沒有,任何解決方法,以便我可以實現目標?

謝謝和問候,Masnun

我懷疑你可以使用站點根目錄中的.htaccess文件來使用它。 如果blog是安裝WordPress的子目錄的名稱,並且您希望word.com/blog由WordPress處理,請嘗試以查看它是否有幫助:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|blog)
RewriteRule ^(.*)$ /index.php/$1 [L]

它應該像你描述的那樣工作,沒有任何復雜的配置。 只需在根目錄中安裝codeigniter,然后創建一個博客目錄並將wordpress放在那里。

用Rich的方法+1

另外,如果您使用的是.htaccess文件,就像在CI文檔中建議的那樣,它應該通過將WP目錄直接刪除到web根目錄來工作。

RewriteEngine On
RewriteBase /

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
#Submitted by Michael Radlmaier (mradlmaier)


RewriteCond $1 !^(index\.php|robots\.txt|corporate|assets)
RewriteRule ^(.*)$ index.php/$1 [L]

由於RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d直接向網絡服務器上的真實文件發出的任何調用都將由Apache直接提供,其他uris將由CI的路由機制來處理。

請注意,我們使用最后一個RewriteCond指令來排除對某些文件的調用,包括我們的資產dir(包含images / css / js靜態文件)和'corporate'dir,在這種情況下包含博客。

雖然這個例子不使用wordpress,但它有自己的url重寫和路由系統。

最后,如果你想使用WP url-rewriting,你將使用特定的RewriteCond語句,如果沒有它可以使用它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM