google site map not working since pretty codeigniter urls - codeigniter

Okay, what is happening!? I switched to pretty urls using code igniter; http://robertwaynehq.com/what-we-do rather than the same with .php
I then updated the site map file and it doesn't seem to like that the pages have no extension. Further the google webmaster site is giving a redirect error. Yet the pages work. Help?
Edit: I do have the redirects in the old files.
<?php
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://mydomain.com/what-we-do" );
?>
The real issue is that I have updated the sitemap.xml and google webmaster tools doesn't seem to like or recognize the files.
<?xml version="1.0" encoding="UTF-8"?>
<urlset>
<url>
<loc>http://mydomain.com/</loc>
<changefreq>weekly</changefreq>
</url>
<url>
<loc>http://mydomain.com/index.php</loc>
<changefreq>weekly</changefreq>
</url>
<url>
<loc>http://mydomain.com/what-we-do</loc>
<changefreq>weekly</changefreq>
</url>
<!-- and so on for each page... -->
</urlset>

set 301 redirect in the old php files, redirecting to the url of the page
Google Webmaster Tools help on 301 Redirect
301 Redirect in PHP

Related

broken header on load sitemap.xml for google search

sitemap.xml not work in my host:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://tcg-wallet.ga/</loc>
<lastmod>2022-12-13T17:12:22+00:00</lastmod>
</url>
</urlset>
located in public, and loaded via: https://tcg-wallet.ga/sitemap.xml
in network i see this:
but when i try to get it working in google search i get this:
i have test it with: https://www.xml-sitemaps.com/ and get this:
i have try handle the content type with .htaccess but is not enough to solve the problem:
<IfModule mod_expires.c>
AddType application/xml xml
</IfModule>
I can't find that it is misconfigured.***

Laravel Spatie Sitemap Package, getting Auth pages too

This is my code in Laravel :
SitemapGenerator::create('https://'.request()->getHost())->writeToFile(request()->getHost().'.xml');
After generating the sitemap I am getting this type of URLs
<url>
<loc>https://example.com/login?redirectTo=https://example.com/posts/wvj/test</loc>
<lastmod>2021-01-20T19:39:59+06:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
Thanks
Use add method.
SitemapGenerator::create('https://example.com')
->getSitemap()
->add(Url::create('/extra-page')
->setLastModificationDate(Carbon::yesterday())
->setChangeFrequency(Url::CHANGE_FREQUENCY_YEARLY)
->setPriority(0.1))
->add(...)
->writeToFile($path);

Spatie Laravel sitemap generated xml file is empty

I am developing a Laravel application. Now, I am trying to implement the sitemap for my website using this package, https://github.com/spatie/laravel-sitemap. But when I generate sitemap.xml, no paths are included in the file.
I installed the package running the Composer command
composer require spatie/laravel-sitemap
Then I published the Composer.
php artisan vendor:publish --provider="Spatie\Sitemap\SitemapServiceProvider" --tag=config
In the routes/web.php, I added this.
Route::get('sitemap', function () {
SitemapGenerator::create('http://app.localhost/')->writeToFile('sitemap.xml');
return "Sitemap generated".
});
When I run the code and sitemap.xml is generated. When I opened the sitemap.xml, that is all I found in it.
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
</urlset>
I have many routes in the web.php. What is wrong and how can fix it?
You can manually add other urls like below and when you run it, the links will be added to your sitemap file:
use Spatie\Sitemap\SitemapGenerator;
use Spatie\Sitemap\Tags\Url;
Route::get('sitemap', function () {
SitemapGenerator::create('https://vesicash.com/')->getSitemap()
->add(Url::create('/link1')->setPriority(0.5))
->add(Url::create('/link2')->setPriority(0.5))
->add(Url::create('/link3')->setPriority(0.5))
->add(Url::create('/privacy')->setPriority(0.5))
->writeToFile('sitemap.xml');
return "Sitemap Generated";
});
This is how I solved this problem:
I just made sure that the APP_URL was set properly in .env file.
I added, for example: https://example.com/ and boom it worked.
This should also work on your local pc as well.
When I did it first time it looked same for me.
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
</urlset>
I think you did it on your local pc.
So first, you can test with this url.
SitemapGenerator::create("https://spatie.be/en")
->writeToFile(public_path('sitemap.xml'));
If it works well, then I believe it will work on server too.
In my case it worked on server, while it was same result with you on my local.

Sitemap is redirecting to non secure site

We have a multilang site and used a sitemap for each lang. Then we used a sitemapindex where we have a mapping of sitemaps avaliable :
<sitemap>
<loc>https://example.com/sitemap_en.xml</loc>
<lastmod>2018-07-10</lastmod>
</sitemap>
<sitemap>
<loc>https://example.com/sitemap_fr.xml</loc>
<lastmod>2018-07-10</lastmod>
</sitemap>
<sitemap>
<loc>https://example.com/sitemap_nl.xml</loc>
<lastmod>2018-07-10</lastmod>
</sitemap>
</sitemapindex>
The sitemap is working ok and valids. However when I pass the console of google and launch the reading of sitemap for indexing, I have a 301 redirect from https to http. That is not happening when I type the url of my site , and i have a rule in my htaccess for avoid this :
RewriteCond %{HTTPS} !on
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Somebody have some idea why when google tries to index the site it gets a redirection from https to http ?

mod_rewrite - redirect to a different url based on existence of x_wap_profile header

We have a desktop and a mobile version of our webapp.
The desktop url is more prominent and so we would like to redirect the user to the mobile version in case the request is for the desktop url from a mobile device.
In the apache config we have the mod_rewrite module
and my config at present looks like this
<IfModule mod_rewrite>
RewriteEngine On
RewriteCond %{x-wap-profile} ^https?://
RewriteRule ^/(.*) http://google.com [L,R]
</IfModule>
At this point this is the only rewrite rule that we have so I'm not sure if L is required because this is the first and last rule anyway.
I have just indicated redirection to google.com for testing purposes
I'm not sure if my condition check is right.I couldn't figure out how to check for existence of a header.Is that what is wrong?If yes,please let me know how to specify the RewriteCond
How I'm Testing?
I'm testing from a Firefox browser and using the Modify headers plugin to simulate the mobile request.I'm adding the x_wap_profile header.
However I don't see any redirect happening with this config.Can you please let me know where I'm going wrong?I would also appreciate if there is any logging that can be introduced here to verify if this rule is being trigerred.I don't see any errors though with the current modified config.
To check for an arbitrary header in mod_rewrite (i.e. a header not in this list), the syntax is:
RewriteCond %{HTTP:x-wap-profile}
This one seems to work:
RewriteEngine On
RewriteCond %{HTTP:x-wap-profile} ^.+
RewriteRule .* http://google.com [L,R]
piotrek#piotrek-Vostro-2520:~/vhosts/localhost$ curl http://localhost/
OKOK
piotrek#piotrek-Vostro-2520:~/vhosts/localhost$ curl -H 'x-wap-profile: abcd' http://localhost/
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved here.</p>
<hr>
<address>Apache/2.4.6 (Ubuntu) Server at localhost Port 80</address>
</body></html>
Change it to make it work for https inside header.
Docs here: http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond in section Other things you should be aware of:.

Resources