Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何优化php页面以在搜索结果中包含用户配置文件页面?_Php_Regex_.htaccess_Mod Rewrite - Fatal编程技术网

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

如何优化php页面以在搜索结果中包含用户配置文件页面?,php,regex,.htaccess,mod-rewrite,Php,Regex,.htaccess,Mod Rewrite,我不知道如何优化profile.php页面以将其包含在搜索结果中。我也试着加入元描述,但什么都没有发生 我在别的地方问过同样的问题,但他们说一定是因为你的.htaccess文件 这是我的.htaccess文件: Options +Indexes # or # IndexIgnore * RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f Re

我不知道如何优化profile.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]

实际上你的规则是不正确的

  • 一般来说,在内部重写之前应该有301条规则
  • 对于尾部斜杠,不需要单独的规则
  • 您的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]
    

    你说的优化是什么意思?这和SEO有关系吗?有点像,但我所说的“优化”是指我应该如何处理每个个人资料页面。我有一个问题,我是否应该包括sitemap,因为它是一个社交网站。我没有在你的网站中看到任何特定于sitemap的规则。htaccessit与seo相关,这就是为什么我要问的原因,因为其中会有许多个人资料页面url,所以包括它是否好。好的,在这种情况下,你可以包括任何特定于sitemap的规则,但一定要测试它。