Viewing 15 replies - 1 through 15 (of 23 total)
  • @tigersaman thanks for your topic.

    While I’m not able to recreate the same on a test site with subfolder installation, I wonder if something specific with the configuration of your site is involved.

    When I visit the AMP version of that blog post, I’m actually taken straight to the incorrect URL. The link to the AMP version from the canonical version goes to this incorrect URL (screenshot). This looks to be the case for the homepage too.

    – Would you happen to know if you have any redirections in place to https://inify.ir/ or are you defining it somewhere else like in the wp-config.php file ?

    – I also notice that a CDN URL is configured for your WordPress URL settings under Settings > General.

    Is this required for the configuration of the service?

    Thread Starter Saman Nezami

    (@tigersaman)

    Thanks for your response.
    Wordpress installation and site url are actually different. It’s not a actual cdn. WordPress is installed in blog-inify.fandogh.cloud and site url Inify.ir/blog

    Thread Starter Saman Nezami

    (@tigersaman)

    Also it might be noteworthy to mention that i cannot change or save plugin setting from setup wizard or amp setting page. it freezes without error. I had to change the settings for Template Mode or mobile redirection from database side ( i copied those to settings from my other site that is working fine ).
    One other thing is wordpress dashboard is hosted on blog-inify.fandogh.cloud and not on inify/blog.

    @tigersaman thanks for the details!

    1) Could you let us know REST API is working properly on your site? A few details that may be helpful:

    – Let us know if you have access to use the default (Gutenberg) editor.

    – From the WordPress Dashboard, go to Tools > Site Health > Status tab and let us know if you see any errors about the REST API (screenshot example).

    Note the that REST API is required for the settings and wizard screen to work properly.

    2) Send us your Site Health information through this form (when the AMP plugin is activated).

    Thread Starter Saman Nezami

    (@tigersaman)

    Thanks for the support.
    1. yes Gutenberg works. and i have no REST API error.
    2. I have submitted the information through the form.
    Also i Have enabled plugin again but disabled mobile redirection but the problem persists. if you check page source you can see that wrong amp url is generated under amphtml tag.
    If there was a way i could hardcode the static first part of url into the code ( inify.ir/blog ) it would be a good temp solution.

    @tigersaman thanks for the info. Yes, it seems mobile redirection is not involved but rather something with the particular configuration of your site.

    Are you able to safely switch to a default theme temporarily to check if the issue persists?

    Thread Starter Saman Nezami

    (@tigersaman)

    I switched to wordpress default theme and disabled plugins one by one and the problem persists.

    @tigersaman thanks for checking and the update!

    Currently, the site isn’t available when I visit it. I can confer with the team about your case, but could you let me know when it is available again so we can evaluate? Thanks so much!

    Thread Starter Saman Nezami

    (@tigersaman)

    It might have been a minor downtime. the site is available most times.
    https://inify.ir/blog

    @tigersaman thanks so much for the follow up. I’m checking your particular case with the team.

    @tigersaman we’re thinking you might be experiencing something similar to what is discussed in this Github issue:

    https://github.com/ampproject/amp-wp/issues/5426

    To confirm a few items:

    1) Is your WordPress installed in a subdirectory?

    2) Are you rewriting $_SERVER['REQUEST_URI'] or are you only rewriting $wp->request?

    Thread Starter Saman Nezami

    (@tigersaman)

    1.the answer is kinda yes. blog is installed in blog-inify.fandogh.cloud and the site url is inify.ir/blog/

    2.Sorry i don’t know that. i only have access to the mentioned locations and not the main server functions. that is why i was asking if it is possible to hardcode “inify.ir/blog/” in the plugin functions.

    from what i read on the github page if we were not using ” $_SERVER[‘REQUEST_URI’]” , we would have a problem in canonical url in wordpress but we don’t have that problem.

    @tigersaman thanks for the information. I’m conferring with the team with these details. We’ll follow up when we have further information about the best next steps.

    Plugin Support Milind More

    (@milindmore22)

    Hi @tigersaman,

    please note it’s not a recommended way to do things, please let me know if this works for you.

    Please use this code in your themes functions.php or in a custom plugin.

    
    add_filter( 'clean_url', 'amp_clean_the_url', 10, 1 );
    
    /**
     * Modify AMP URL.
     *
     * @param string $good_protocol_url The cleaned URL to be returned.
     */
    function amp_clean_the_url( $good_protocol_url ) {
    
    	$parsed_url = wp_parse_url( $good_protocol_url, PHP_URL_QUERY );
    
    	if ( ! empty( $parsed_url ) && ( 'amp' === $parsed_url || 'amp=1' === $parsed_url ) ) {
    
    		$new_url_scheme = wp_parse_url( $good_protocol_url, PHP_URL_SCHEME );
    		$new_url_host   = wp_parse_url( $good_protocol_url, PHP_URL_HOST );
    		$new_url_path   = wp_parse_url( $good_protocol_url, PHP_URL_PATH );
    
    		$new_url = $new_url_scheme . '://' . $new_url_host . '/blog' . $new_url_path;
    
    		$new_url = add_query_arg( amp_get_slug(), '1', $new_url );
    
    		return $new_url;
    
    	}
    
    	return $good_protocol_url;
    }
    
    Thread Starter Saman Nezami

    (@tigersaman)

    Thank you for the custom code
    i have added the code and it works in creating a true url for amphtml but when i activate mobile redirection, it redirects to the wrong url.

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘wrong mobile redirection’ is closed to new replies.