How to set up a Wordpress application in a subdirectory using a simple php application using .htaccess / Apache2?

I want to configure a Wordpress application with a simple php application. The application directory structure is as follows:

Root directory: / var / www / demoApp /

Wordpress Directory: / var / www / demoApp / wordpress /

Here I want to access the wordpress application using the route http: // BASE_URL / wordpress . But I can not configure the htaccess file. All php pages in the / var / www / demoApp / directory work fine using the url http: // BASE_URL / . While Wordpress files do not load correctly.

Here is my Apache configuration block:

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

+5
2

:

domain: test.localhost

wordpress url: test.localhost/wordpress

.htaccess wordpress:

# 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 (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>
+2

.

, / .

<a href="about">About</a>   Correct, relates to http://BASE_URL/wordpress/about
<a href="about">/About</a>  This is relative to the 'Root'. Goes to http://BASE_URL/about
0

Source: https://habr.com/ru/post/1679332/


All Articles