简体   繁体   English

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

[英]How to configure wordpress application in subdirectory with simple php application using .htaccess / Apache2?

I want to configure a Wordpress application with a simple php application. 我想用一个简单的php应用程序配置一个Wordpress应用程序。 The directory structure of the application is as follow : 应用程序的目录结构如下:

Root directory : /var/www/demoApp/ 根目录:/ var / www / demoApp /

Wordpress directory : /var/www/demoApp/wordpress/ Wordpress目录:/ var / www / demoApp / wordpress /

Here i want to access the wordpress application using route http://BASE_URL/wordpress . 在这里,我想使用路由http:// BASE_URL / wordpress访问wordpress应用程序。 But i am not able to configure the htaccess file. 但我无法配置htaccess文件。 All the php pages under /var/www/demoApp/ directory are working fine using url http://BASE_URL/ . 使用url http:// BASE_URL / ,/ var / www / demoApp /目录下的所有php页面都正常工作。 While wordpress files are not being loaded correctly. 虽然没有正确加载wordpress文件。

Here is my Apache configuration block : 这是我的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>

What should be the .htaccess file? 什么应该是.htaccess文件?

My configuration: 我的配置:

domain: test.localhost domain:test.localhost

wordpress url: test.localhost/wordpress wordpress url:test.localhost / wordpress

.htaccess in the wordpress folder: 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 settings for the subdomain (Wamp server under windows) 子域的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>

I had this issue while trying to modify a few absolute paths to relative paths. 我在尝试修改相对路径的一些绝对路径时遇到了这个问题。 The problem was that I left an extra / at the start of the relative path. 问题是我在相对路径的开头留下了一个额外的/

Correct Code: 正确的代码:

<a href="about">About</a>   
<!--The link goes to to http://BASE_URL/wordpress_subdirectory/about-->

Errorneous code: 错误的代码:

<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.

相关问题 如何为子目录配置.htaccess - How to configure .htaccess for subdirectory 带有Web应用程序的自定义PHP / Apache2安装程序 - Custom PHP/Apache2 Installer with web application 如何从本地运行的AngularJS应用程序中使用apache2代理设置访问localhost upload.php - How can I access localhost upload.php using apache2 proxy setting from my locally running AngularJS application 使用htaccess在WordPress中隐藏子目录 - Hide subdirectory in WordPress using htaccess 使用.htaccess重写到Wordpress子目录? - Using .htaccess to rewrite to Wordpress subdirectory? 如何使用.htaccess在Apache-FastCGI-PHP应用程序上扩展请求/连接超时 - How to Extend the Request/Connection Timeout on Apache-FastCGI-PHP application using .htaccess Linux Apache2 Wordpress核心位于子目录中,但没有重定向到wp-admin - Linux Apache2 Wordpress core in subdirectory but no redirect to wp-admin 如何在没有 javascript 的情况下使用 Apache 服务器在 PHP 中创建简单的 websocket 聊天应用程序 - How to create simple websocket chat application in PHP using Apache server without javascript 如何使用apache2在localhost中部署symfony2应用程序 - How to deploy symfony2 application in localhost with apache2 如何在子目录 Laravel 中正确配置 htaccess? - How to correctly configure htaccess in subdirectory Laravel?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM