谷歌SEO友好的URL使用.htaccess



我运行了一个论坛,我正在尝试修改.htaccess,以便我们可以拥有更友好的URL。

这是我的.htaccess。我们在网站上使用SSL证书,并希望强制HTTPS:)

RewriteEngine On
# Some hosts require RewriteBase to make RewriteRules work.
RewriteBase /
RewriteRule ^([^&]*)&(.*)$ https://example.com/$1?$2 [L,QSA,R=301]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule !/status https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
ErrorDocument 404 /error.php
# Google SEO workaround for search.php highlights:
# Make this rule the first rewrite rule in your .htaccess!
RewriteRule ^([^&]*)&(.*)$ https://example.com/$1?$2 [L,QSA,R=301]
# Google SEO 404:
ErrorDocument 404 /misc.php?google_seo_error=404
# Google SEO Sitemap:
RewriteRule ^sitemap-([^./]+).xml$ misc.php?google_seo_sitemap=$1 [L,QSA,NC]
# Google SEO URL Forums:
RewriteRule ^Forum-([^./]+)$ forumdisplay.php?google_seo_forum=$1 [L,QSA,NC]
# Google SEO URL Threads:
RewriteRule ^Thread-([^./]+)$ showthread.php?google_seo_thread=$1 [L,QSA,NC]
# Google SEO URL Announcements:
RewriteRule ^Announcement-([^./]+)$ announcements.php?google_seo_announcement=$1 [L,QSA,NC]
# Google SEO URL Users:
RewriteRule ^User-([^./]+)$ member.php?action=profile&google_seo_user=$1 [L,QSA,NC]
# Google SEO URL Calendars:
RewriteRule ^Calendar-([^./]+)$ calendar.php?google_seo_calendar=$1 [L,QSA,NC]
# Google SEO URL Events:
RewriteRule ^Event-([^./]+)$ calendar.php?action=event&google_seo_event=$1 [L,QSA,NC]

如有任何帮助,我们将不胜感激:)

这是我用来实现HTTPS的三行代码。

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

我还注意到你没有

IndexIgnore *

在那里,这真的很好,因为它阻止了人们将您的web目录作为索引查看(可以看到您的文件和文件夹目录的名称)

相关内容

  • 没有找到相关文章

最新更新