• Hi,

    I’m running WP 4.2.2 on AWS using a Bitnami WP image. I added rewrites to conf/httpd-vhosts.conf (contains <VirtualHost>) to rewrite any host that doesn’t match my preferred hostname (find example of vhosts below.) This change works fine for everything except permalinks. Just incase my explanation isn’t clear, here is an example;

    https://aws-hostname.com/wordpress redirects to
    https://www.website.com/wordpress

    https://aws-hostname.com/wordpress/permalink does not redirect at all.

    I’ve made sure that the hostname is correct in wp-config.php, checked the permalink settings in the WP dashboard to confirm it does display the proper hostname and restarted the server just incase some change was not taking effect. I’ve included a copy of my htaccess config below. I’m sure I’m missing something here, but I can’t seem to figure out what it is. Any ideas would be appreciated. Thanks.

    vhosts config:

    <VirtualHost *:80>
      ServerName www.website.com
      DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
      Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
      RewriteEngine On
      RewriteCond %{HTTP_HOST} !^www.website.com$
      RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
      RewriteRule ^(.*)$ https://www.website.com$1 [R=permanent,L]
    </VirtualHost>
    
    <VirtualHost *:443>
      ServerName www.website.com
      DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
      RewriteEngine On
      RewriteCond %{HTTP_HOST} !^www.totalboatshow.com$
      RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
      RewriteRule ^(.*)$ https://www.totalboatshow.com$1 [R=permanent,L]
      SSLEngine on
      SSLCertificateFile "/opt/bitnami/apps/wordpress/conf/certs/server.crt"
      SSLCertificateKeyFile "/opt/bitnami/apps/wordpress/conf/certs/server.key"
      Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
    </VirtualHost>

    htaccess / <Directory>:

    <Directory "/opt/bitnami/apps/wordpress/htdocs">
        Options +MultiViews +FollowSymLinks
        AllowOverride None
        <IfVersion < 2.3 >
        Order allow,deny
        Allow from all
        </IfVersion>
        <IfVersion >= 2.3>
        Require all granted
        </IfVersion>
        RewriteEngine On
        RewriteBase /
        RewriteRule ^index\.php$ - [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /wordpress/index.php [L]
    </Directory>

  • The topic ‘Permalinks not obeying hostname rewrite’ is closed to new replies.