iulia zidaru
iulia zidaru

Reputation: 201

How to configure wordpress blog in subdirectory when the main site has angular 1.5 pretty URL

I have a website deployed in Apache: http://mysite.test. I need to configure wordpress at http://mysite.test/blog. I tried to configure it with alias, but it keep redirecting to the default page of the main site. The main site has Angular 1.5 with pretty URLs configured. Here is the apache configuration:

<VirtualHost *:80>
    DocumentRoot "/Users/iulia/git/mysite/app/src"
    ServerName mysite.test
    ErrorLog /Users/iulia/tmp/error.log
    CustomLog /Users/iulia/tmp/access.log combined

     Alias /blog "/Users/iulia/git/mysite/blog"
    <Directory "/Users/iulia/git/mysite/blog">
        Options FollowSymLinks
        allow from all
        AllowOverride All
        Require all granted
    </Directory>

    <Directory "/Users/iulia/git/mysite/app/src">
        AllowOverride All
        Require all granted
     </Directory>


    # Angular HTML5 routes
    RewriteEngine On
    # If an existing asset or directory is requested go to it as it is
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
    RewriteRule ^ - [L]

    # If the requested pattern is file and file doesn't exist, send 404
    RewriteCond %{REQUEST_URI} ^(\/[a-z_\-\s0-9\.]+)+\.[a-zA-Z]{2,4}$
    RewriteRule ^ - [L,R=404]

    # otherwise use history router
    RewriteRule ^ /index.html

    SetOutputFilter DEFLATE
    SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip

Upvotes: 0

Views: 119

Answers (1)

iulia zidaru
iulia zidaru

Reputation: 201

It worked when removing Directory with the root folder and added RewriteCond %{REQUEST_URI} !^/blog/(.*):

<VirtualHost *:80>
    DocumentRoot "/Users/iulia/git/mysite/app/src"
    ServerName mysite.test
    ErrorLog /Users/iulia/tmp/feUserError.log
    CustomLog /Users/iulia/tmp/feUserAccess.log combined

     Alias /blog "/Users/iulia/git/mysite/blog"
    <Directory "/Users/iulia/git/mysite/blog">
        Options FollowSymLinks
        allow from all
        AllowOverride All
        Require all granted
    </Directory>

 # <Directory "/Users/iulia/git/mysite/app/src">
 #     AllowOverride All
 #    Require all granted
 #       </Directory>


    # Angular HTML5 routes
    RewriteEngine On
    # If an existing asset or directory is requested go to it as it is
     RewriteCond %{REQUEST_URI} !^/blog/(.*)
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
    RewriteRule ^ - [L]

    # If the requested pattern is file and file doesn't exist, send 404
     RewriteCond %{REQUEST_URI} !^/blog/(.*)
    RewriteCond %{REQUEST_URI} ^(\/[a-z_\-\s0-9\.]+)+\.[a-zA-Z]{2,4}$
    RewriteRule ^ - [L,R=404]

    # otherwise use history router
     RewriteCond %{REQUEST_URI} !^/blog/(.*)
    RewriteRule ^ /index.html

    SetOutputFilter DEFLATE
    SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip

Upvotes: 1

Related Questions