我需要从中转发/重定向域
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/