1

I have a problem with my domain for selected canonical url by google.

I have a vps for my website with apache. I created a redirect for website ip, but some domains have my ip in DNS and redirect to my domain and google selects another domain as the canonical url. (not mine).

I also put in the head tag on the website a link that shows the correct canonical url.

What should I do for google to select the correct url address?

Apache config: (i use apache 2.4.41)

<VirtualHost example.com:80>
    ServerAdmin webmaster@localhost
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com
    Redirect permanent / https://example.com/
    
    #error logs
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost example.com:443>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com

    <If "%{HTTP_HOST} != 'www.example.com' && %{HTTP_HOST} != 'example.com'">
        Redirect permanent / https://example.com/
    </If>

    <If "%{HTTP_HOST} == 'www.example.com'">
        Redirect permanent / https://example.com/
    </If>

    SSLEngine on
    SSLCertificateFile        ...
    SSLCertificateKeyFile     ...
    SSLCertificateChainFile   ...
</VirtualHost>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.