如何使用.htaccess / Apache2在简单的php应用程序中配置wordpress应用程序在子目录中?

问题描述 投票:5回答:2

我想用一个简单的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文件?

php wordpress apache .htaccess mod-rewrite
2个回答
2
投票

我的配置:

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>

0
投票

我在尝试修改相对路径的一些绝对路径时遇到了这个问题。问题是我在相对路径的开头留下了额外的/

正确的代码:

<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-->
© www.soinside.com 2019 - 2024. All rights reserved.