0

我想将网址从:
http://subdomain.domain.com/page/tohttp://subdomain.domain.com/?page=pagename
和also:
http://domain.com/page/to更改为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的似乎适用于域 url 但不适用于子域。任何帮助,将不胜感激。

4

2 回答 2

0

So it was an easy fix really. I basically put a .htaccess file in each subdomain directory that looks like this:

Options +FollowSymlinks -MultiViews

RewriteEngine On
RewriteBase /

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

Hope this helps someone. :D

于 2013-02-03T13:53:48.957 回答
0

实际上最近不得不做这样的事情。试试这个为您的子域重定向块:

  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]
于 2013-02-02T03:49:51.417 回答