Php Htaccess将URL从一个转发到另一个

Php Htaccess将URL从一个转发到另一个,php,linux,.htaccess,redirect,Php,Linux,.htaccess,Redirect,我需要转发/重定向来自的域 http://local.abcxyz.com/be/country/CN/BE 到 如何使用.htaccess执行此操作 我当前的htaccess文件如下所示 RewriteEngine On # If the file or directory exists, show it RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d

我需要转发/重定向来自的域

  http://local.abcxyz.com/be/country/CN/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]

此访问权限存在于be文件夹中

您可以在
文档根/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。

该评论对任何人都没有帮助。问题0。您在浏览器中输入的URL是什么?问题1。这是唯一的.htaccess还是你有其他的?问题2。这是这个.htaccess中唯一的代码吗?如果你有一些其他的代码,那么请张贴它的问题?第三季度。上面的.htaccess的位置是什么?第四季度。您是否确保启用了
mod_rewrite
.htaccess
?我已在问题中添加了所有必需的信息。现有的htaccess,还有它的位置。我不想重写url,请再次阅读问题我需要将旧的url转发到新的url。新的url运行良好。我需要的是,当我输入旧的url时,它会自动重定向/转发到新的url。希望对大家都有帮助。@anubhava我想你还没有看到新的“ThisHTAccess存在于be文件夹”Q0。您在浏览器中输入的URL是什么?A0。问题1。这是唯一的.htaccess还是你有其他的?A1。根目录中有两个目录,be和nl,be和nl目录中有htaccess。问题2。这是这个.htaccess中唯一的代码吗?如果你有一些其他的代码,那么请张贴它的问题?A2。nl目录中存在相同的htaccess。第三季度。上面的.htaccess的位置是什么?A3。root/be/.htaccess Q4。您是否确保启用了mod_rewrite和.htaccess?A4。我正在使用CodeIgniter。Htaccess和mod_rewrite已启用。
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]