簡體   English   中英

.htaccess mod用變量重寫

[英].htaccess mod rewrite with variable

我正在嘗試為我的網站做一個簡單的重定向,但運氣不佳。

我的.htaccess是:

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine On

    RewriteBase /
    RewriteCond %{HTTP_HOST} ^(es|fr|pt|de|zh|ru|my|in|ae|bd)\.my-site\.com$
    RewriteRule (.*) - [QSA,E=LANGUAGE:%1]
    RewriteCond %{ENV:LANGUAGE} ^$
    RewriteRule (.*) - [QSA,E=LANGUAGE:en]
    RewriteRule (.*) $1?language=%{ENV:LANGUAGE} [QSA]

RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^profile/(.*)$ http://my-site/decorators/profile/$1
RewriteRule ^(.*)$ index.php

http://my-site/decorators/profile/whatever if用戶瀏覽到http://my-site/profile/whatever我希望它重定向到http://my-site/decorators/profile/whatever if http://my-site/profile/whatever

添加以下htaccess代碼

  RewriteCond ^([profile]+)/(.*)$
  RewriteRule ^([decorators]+)/([profile]+)/(.*)$

在htaccess中刪除以下代碼

  RewriteRule ^profile/(.*)$ http://my-site/decorators/profile/$1

有這樣的規則:

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine On
RewriteBase /

RewriteRule ^(profile/.*)$ /my-site/decorators/$1 [NC,L,R=302]

RewriteCond %{HTTP_HOST} ^(es|fr|pt|de|zh|ru|my|in|ae|bd)\.my-site\.com$
RewriteRule (.*) - [QSA,E=LANGUAGE:%1]

RewriteCond %{ENV:LANGUAGE} ^$
RewriteRule (.*) - [QSA,E=LANGUAGE:en]

RewriteRule (.*) $1?language=%{ENV:LANGUAGE} [QSA,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM