[英]How to configure wordpress application in subdirectory with simple php application using .htaccess / Apache2?
我想用一個簡單的php應用程序配置一個Wordpress應用程序。 應用程序的目錄結構如下:
根目錄:/ var / www / demoApp /
Wordpress目錄:/ var / www / demoApp / wordpress /
在這里,我想使用路由http:// BASE_URL / wordpress訪問wordpress應用程序。 但我無法配置htaccess文件。 使用url http:// BASE_URL / ,/ var / www / demoApp /目錄下的所有php頁面都正常工作。 雖然沒有正確加載wordpress文件。
這是我的Apache配置塊:
<VirtualHost *:80>
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /var/www/demoApp
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/demoApp>
Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
什么應該是.htaccess文件?
我的配置:
domain:test.localhost
wordpress url:test.localhost / wordpress
wordpress文件夾中的.htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
子域的Apache設置(Windows下的Wamp服務器)
<VirtualHost *:80>
DocumentRoot "e:\Sync\www\test"
ServerName localhost
ServerAlias test.localhost
<Directory "e:\Sync\www\test">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
</Directory>
</VirtualHost>
我在嘗試修改相對路徑的一些絕對路徑時遇到了這個問題。 問題是我在相對路徑的開頭留下了一個額外的/
。
正確的代碼:
<a href="about">About</a>
<!--The link goes to to http://BASE_URL/wordpress_subdirectory/about-->
錯誤的代碼:
<a href="about">/About</a>
<!--This href is relative to the 'Root'. It goes to http://BASE_URL/about-->
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.