如何优化 php 页面以在搜索结果中包含用户配置文件页面



我不知道如何优化我的个人资料.php页面以将其包含在搜索结果中。 我也试图包括元描述,但什么也没发生。

我在其他地方问过同样的问题,但他们说这一定是因为你的.htaccess文件。

这是我的.htaccess文件:

Options +Indexes
# or #
IndexIgnore *
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9._-]+)$ profile.php?u=$1 
RewriteRule ^([a-zA-Z0-9._-]+)/$ profile.php?u=$1
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

实际上你的规则不正确。

    通常,在
  1. 内部重写之前,您应该有 301 规则。
  2. 您不需要仅针对尾部斜杠的单独规则。
  3. 您的 2 个重写条件不适用于第 2 个重写规则。

请尝试以下规则:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9._-]+)/?$ profile.php?u=$1 [L,QSA]

最新更新