php - Htaccess 将 URL 从一个转发到另一个

标签 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 存在于 be 文件夹中。

最佳答案

您可以在您的 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。

关于php - Htaccess 将 URL 从一个转发到另一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27600216/

相关文章:

.htaccess - 基于 htaccess 的纯数字 URL 重定向

php - htaccess 检查查询字符串是否为空

有响应时 PHP SoapClient 故障

php - Laravel:如何创建迁移文件以从表中删除多列?

php - 使用 IF ELSE 和循环查找 MySql 中的最高、中间和最低值

c++ - 如何在不将目录包含到彼此的编译命令中的情况下构建目标?

php - 在python中压缩base64字符串并在PHP中提取它

linux - 我们如何检查 Linux 中是否启用了 NAPI 功能?

linux - 使用打印两个不同的文件字段

.htaccess - 通过 htaccess 和分页获得值(value)