发行与子域和htaccess的搜索引擎优化(Issue with subdomains and ht

2019-11-01 12:58发布

我想从更改网址:
http://subdomain.domain.com/page/http://subdomain.domain.com/?page=pagename
并且:
http://domain.com/page/http://domain.com/?page=pagename
虽然没有太多的成功。

这里是我的htaccess文件至今[更新]

Options +FollowSymlinks -MultiViews

RewriteEngine On
RewriteBase /

# Remove 'www'
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

# Add slashes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://resolutiongaming.com/$1/ [L,R=301]

# Subdomain redirect
RewriteRule ^/(webdev)/(.*)$ http://webdev.resolutiongaming.com/$1 [R=301,L]
RewriteRule ^/(artwork)/(.*)$ http://artwork.resolutiongaming.com/$1 [R=301,L]
RewriteRule ^/(music)/(.*)$ http://music.resolutiongaming.com/$1 [R=301,L]

# Search engine optimization
RewriteRule ([a-zA-Z]+)/$ ?page=$1

我用RewriteRule ^([a-zA-Z]+)/$ ?page=$1这似乎对域名网址而不是子域工作。 任何帮助,将不胜感激。

Answer 1:

实际上有最近做这样的事情。 试试这个为你的子域名重定向块:

  RewriteRule ^/(webdev)/(.*)$ http://webdev.resolutiongaming.com/$2 [R=301,L]
  RewriteRule ^/(artwork)/(.*)$ http://artwork.resolutiongaming.com/$2 [R=301,L]
  RewriteRule ^/(music)/(.*)$ http://music.resolutiongaming.com/$2 [R=301,L]

或者,也许这一点; 注意从$ 2$ 1的变化:

  RewriteRule ^/(webdev)/(.*)$ http://webdev.resolutiongaming.com/$1 [R=301,L]
  RewriteRule ^/(artwork)/(.*)$ http://artwork.resolutiongaming.com/$1 [R=301,L]
  RewriteRule ^/(music)/(.*)$ http://music.resolutiongaming.com/$1 [R=301,L]

编辑:或者,也许试试这个。 请注意,您需要捕获URL的两个部分改写为您讲解。 在括号中的每一项()对应于重写的字符串。 尝试这个。 使用您更好的正则表达式RewriteRule ,你在评论中提到:

  RewriteRule ^([a-zA-Z]+)/(.*)$ /$1/$2 [R=301,L]

或者,也许这样的:

  RewriteRule ^([a-zA-Z]+)/(.*)$ /$1/page=$2 [R=301,L]


Answer 2:

所以这是一个简单的办法真的。 我基本上把.htaccess文件中看起来像这样每个子域目录:

Options +FollowSymlinks -MultiViews

RewriteEngine On
RewriteBase /

# Search engine optimization
RewriteRule ([a-zA-Z]+)/$ ?page=$1

希望这可以帮助别人。 :D



文章来源: Issue with subdomains and htaccess for SEO