Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Update relative-urls.php #123

Closed
wants to merge 1 commit into from
Closed

Update relative-urls.php #123

wants to merge 1 commit into from

Conversation

z-avanes
Copy link

@z-avanes z-avanes commented Nov 1, 2015

some sitemap plugin like yoast seo generate url for sitemap like :
http://domain.com/post-sitemap1.xml
http://domain.com/page-sitemap.xml
http://domain.com/post_tag-sitemap4.xml
...
and prev regex cannot handel this type of url and cause of error in google webmaster
the new regex fix this problem

some sitemap plugin like yoast seo generate url for sitemap like :
http://domain.com/post-sitemap1.xml
http://domain.com/page-sitemap.xml
http://domain.com/post_tag-sitemap4.xml
...
and prev regex cannot handel this type of url and cause of error in google webmaster
the new regex fix this problem
@retlehs
Copy link
Member

retlehs commented Nov 9, 2015

are you actually experiencing an issue? i tried to reproduce this problem and i can't. in fact, i can completely remove the entire check at the top of relative-urls.php and the sitemaps generated from wordpress seo don't have any relative URLs.

we filter the_permalink, and wordpress seo uses get_permalink to generate their sitemaps

@retlehs
Copy link
Member

retlehs commented Nov 9, 2015

even when i add the_permalink to the relative list i can't get the sitemap to show relative URLs. are you still experiencing this with the latest soil / latest wordpress seo?

@z-avanes
Copy link
Author

z-avanes commented Nov 9, 2015

hi
yes i experience problem in sitemap tags section when count of tags increase and wordpress seo genarate tag sitemap with this pattern /post_tag-sitemap1.xml, /post_tag-sitemap2.xml ...
at this moment this regex /sitemap(index)?.xml/ dont work and in sitemap tags section url convert to relative and google webmaster have problem with this type url and display error
please increase tags to force wp seo genearate page and then test code
this is my final regex fix problem /^/[a-zA-Z0-9
-]_sitemap(index)?\d.xml$/

@retlehs
Copy link
Member

retlehs commented Nov 9, 2015

thanks. both the regex in this PR and the regex you just provided don't work to fix the problem, which i was able to reproduce after adding tags and viewing the tags sitemap

@retlehs
Copy link
Member

retlehs commented Nov 9, 2015

try replacing the regex with isset($_GET['sitemap'])

(from @Foxaii via https://github.com/roots/soil/issues/16#issuecomment-52793074)

@z-avanes
Copy link
Author

replace but nothing happen and tags and category sitemap convert relative
also test this function in extras.php but same thing happen

function disable_soil_relative_urls_sitemap() {
    if (isset($_GET['sitemap'])) {
        remove_theme_support('soil-relative-urls'); // Disable relative URLs from Soil
    }
}
add_filter('after_setup_theme', __NAMESPACE__ . '\\disable_soil_relative_urls_sitemap');

are you sure $_GET['sitemap'] set in sitemap request?

@z-avanes
Copy link
Author

main reason of this problem is number and if simplify my prev regex get better thing
/sitemap(_index)?\d*.xml$/

be careful in test process sitemap cache and when php code change maybe see prev generated xml

@retlehs
Copy link
Member

retlehs commented Nov 19, 2015

i went into wordpress seo and completely disabled the caching in the sitemaps. i made sure that it was disabled by removing preg_match('/sitemap(_index)?\.xml/', $_SERVER['REQUEST_URI']) from relative-urls.php while refreshing the post tag sitemap (post_tag-sitemap.xml) on the frontend and saw that the URLs were being correctly shown as expected

also confirmed that with isset($_GET['sitemap']) it works as expected, so i'll be committing that here in a minute

@retlehs retlehs closed this Nov 19, 2015
retlehs added a commit that referenced this pull request Nov 19, 2015
@z-avanes
Copy link
Author

the sitemap problem stile remain #156
i have problem in tag sitemap section and when number of page increase and have sitemap url like this
http://domain.com/post_tag-sitemap1.xml
http://domain.com/post_tag-sitemap2.xml
i am use this regex to solve problem
preg_match('/sitemap.*.xml/', $_SERVER['REQUEST_URI'])

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants