404エラーになる問題
解決したいこと
こんにちは、私は自分のウェブサイトで問題が発生しています。サイトマップがGooglebotによってクロールされないことです。以下は私が行った対応です。
PHPでサイトマップを生成しました(sitemap.php)。
robots.txtでGooglebotのアクセスを許可し、特定のディレクトリを除外しました。
.htaccessファイルを設定し、特定のファイルアクセスを許可または拒否しました。
しかし、Google Search Consoleで、サイトマップへのアクセス時に一般的なHTTPエラー(404)が報告されています。ブラウザでサイトマップにアクセスすると、正しく表示されます。
以下はrobots.txtの内容です:
User-agent: bingbot
Crawl-Delay: 120
User-agent: msnbot
Crawl-Delay: 120
User-agent: *
Disallow: /rank_area/
Disallow: /search?*
Disallow: /collection?
User-agent: Googlebot
Disallow: /rank_area/
Disallow: /search?*
Disallow: /collection?
Allow: /sitemap.php
私はこれまでにすべての対応を行いましたが、未だに404エラーになります。原因と対策について、どなたか助けていただけませんか?よろしくお願いします。
発生している問題・エラー
検出
ライブテストでは確認できません
クロール 時間 2023/04/15 5:00:34
ユーザー エージェント スマートフォン用 Googlebot
クロールを許可? はい
ページの取得 error
失敗しました: 見つかりませんでした(404)
インデックス登録を許可? 該当なし
インデックス作成
ユーザーが指定した正規 URL 該当なし
Google が選択した正規 URL インデックス登録後にのみ決定されます
File:.htaccess
# File access
<Files ~ "\.(db|log|ini)$">
Require all denied
</Files>
<Files "*.php">
MultiviewsMatch Any
</Files>
# Add an exception for the robots.txt file
<Files "robots.txt">
Require all granted
</Files>
<IfModule mod_headers.c>
Header set Content-Language "ja"
</IfModule>
# Allow Googlebot access
SetEnvIfNoCase User-Agent "Googlebot" allow_bot
SetEnvIfNoCase User-Agent "Googlebot-Mobile" allow_bot
SetEnvIfNoCase User-Agent "Googlebot-Image" allow_bot
SetEnvIfNoCase User-Agent "Googlebot-Video" allow_bot
SetEnvIfNoCase User-Agent "Googlebot-News" allow_bot
# Rewrite rule for Apache 2.4
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{ENV:allow_bot} !^1$
RewriteRule !\.(pdf|ico|gif|jpg|png|css|html|xml|txt)$ index.php [NC,L]
</IfModule>
# Cache settings
ExpiresActive On
ExpiresByType image/gif "access plus 1 weeks"
ExpiresByType image/jpeg "access plus 1 weeks"
ExpiresByType image/png "access plus 1 weeks"
ExpiresByType application/x-shockwave-flash "access plus 1 years"
ExpiresByType application/rss+xml "access plus 30 minutes"
ExpiresByType application/x-javascript "access plus 20 days"
ExpiresByType text/html "modification plus 15 minutes"
ExpiresByType text/css "access plus 20 days"
# Cache control
<ifModule mod_headers.c>
<filesMatch "\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "s-maxage=86400, public"
</filesMatch>
</ifModule>
# gzip
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
# Older browser support
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch \bMSIE\s(7|8) !no-gzip !gzip-only-text/html
# Don't compress images: GIF, JPEG, PNG, ICO
SetEnvIf Request_URI \.(?:gif|jpe?g|png|ico)$ no-gzip dont-vary
# Compress files
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-font-woff
AddOutputFilterByType DEFLATE application/x-font-opentype
</IfModule>
0 likes