问题描述
我需要robots.txt
推荐下一个:
我已经为msub.PHP
中的RewriteReuls
做过.htaccess
的链接,如下所示:
domain.com/p/subject122
domain.com/p/subject104
所以我想使链接显示在搜索引擎中,就像:domain.com/p/subject122。
我该怎么做?
我尝试了此命令,但效果不佳。.链接:domain.com/p/subject104
未出现在搜索引擎中
User-agent: *
disallow: /
Allow: /index.PHP
Allow: /msub.PHP
.htaccess
Options -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
RewriteCond %{REQUEST_URI} ^/404/$
RewriteRule ^(.*)$ /error.html [L]
RewriteRule home /index.PHP
RewriteRule p/(.*)$ msub.PHP?page=$1
解决方法
robots.txt
应该包含搜寻器看到的URI,无论您如何内部处理它们。因此,您的robots.txt
应该具有:
User-agent: *
Disallow: /
Allow: /p/subject122
Allow: /p/subject104
您的.htaccess也可以重构:
Options -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} 80
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,NE,L]
RewriteRule ^404/?$$ error.html [L,NC]
RewriteRule ^home/?$ index.php [L,NC]
RewriteRule p/(.*)$ msub.php?page=$1 [L,NC,QSA]