Htaccess转发URL从一个到另一个

时间:2014-12-22 09:53:11

标签: php linux .htaccess redirect

我需要从

转发/重定向域名
  http://local.abcxyz.com/be/country/CN/BE

http://local.abcxyz.com/be/country/visum-china/BE

我怎样才能使用.htaccess?

我当前的htaccess文件看起来像这样

  RewriteEngine On

    # If the file or directory exists, show it
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^(.+) - [PT,L]
    # Blank queries get sent to the index
    #RewriteRule ^$ index.php [L]
    # All other queries get sent to the index as index.php/whatever
    #RewriteRule ^(.*)$ index.php/$1 [L]

    RewriteCond $1 !^(index\.php|images|swf|uploads|js|css|robots\.txt)
    RewriteRule ^(.*)$ /be/index.php/$1 [L]

这个htaccess存在于文件夹中。

1 个答案:

答案 0 :(得分:3)

您可以在DOCUMENT_ROOT/be/.htaccess文件中使用此代码:

RewriteEngine On
RewriteBase /be/

RewriteRule ^country/CN/BE/?$ country/visum-china/BE [L,NC]

# If the file or directory exists, show it
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteCond $1 !^(index\.php|images|swf|uploads|js|css|robots\.txt)
RewriteRule ^(.+)$ index.php/$1 [L]

假设/country/或以下任何目录中没有.htaccess。