I have scoured several pages, answers and articles in an attempt to correctly configure Apache Alias and WordPress Permalinks without success.
/var/www/
| - example.com (Custom Web App)
| - blog.example.com (WordPress)
Using the structure above, I am able to access WordPress without any issues, including permalinks such as https://blog.example.com/sample-post/
.
I have added an alias in Apache as shown below:
<VirtualHost *:443>
ServerName example.com
DocumentRoot /var/www/example.com/public
Alias /blog /var/www/blog.example.com
<Directory /var/www/example.com/public>
AllowOverride all
Options -Multiviews
Require all granted
</Directory>
</VirtualHost>
After making those changes, restarting apache and updating the wordpress address
and site address
in the WordPress settings area, I can access the site at the desired URL https://example.com/blog
but permalinks return 404 errors.
I find that I must switch to plain URLs to get posts to load. I have made no changes to the .htaccess
file, however this is the content:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
The objective is to access WP posts at https://example.com/blog/sample-post/
Any help is appreciated.
Best Answer
I solved the same issue by changing the configuration.
When you use Alias /blog then accessing WP posts using permalink example.com/blog/sample-post/ will be redirected to example.com by Apache so you get 404 error.
I was using Reverse Proxy and to ignore redirects my setting was:
Now for Alias /blog we should change following RewriteRule to apache configuration to allow permalinks wroks:
It works for me.