Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. The directory structure of the application is as follow :

Root directory : /var/www/demoApp/

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

Here i want to access the wordpress application using route http://BASE_URL/wordpress. But i am not able to configure the htaccess file. All the php pages under /var/www/demoApp/ directory are working fine using url http://BASE_URL/. While wordpress files are not being loaded 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?

like image 497
Nitesh Avatar asked Jun 15 '17 10:06

Nitesh


1 Answers

My configuration:

domain: test.localhost

wordpress url: test.localhost/wordpress

.htaccess in the wordpress folder:

# 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)

<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>
like image 154
Peter Matisko Avatar answered Nov 09 '22 18:11

Peter Matisko