每当有人尝试www.domain.com/store/bg/user/login
时,我都会尝试重定向到www.domain.com/STOREADMIN/bg/user/login
(大写只是为了强调)。网址的语言部分可以是另一种语言(.../../en/../..
)。
这是整个.htaccess
文件:
Options -Indexes
# follow symbolic links
Options FollowSymlinks
RewriteEngine on
#RewriteRule ^(store)($|/) - [L]
#RewriteRule ^/store/(.+) http://store.tashev.bg/$1 [R,L]
RewriteCond %{REQUEST_URI} ^/storeadmin/[a-z]{2}/user/login
RewriteRule ^/storeadmin/([a-z]{2}) %{HTTP_HOST}/store/$1/user/login [R=301,L]
RewriteCond %{REQUEST_URI} ^/admin/$
RewriteRule ^(admin)/$ /$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/admin
RewriteRule ^admin(/.+)?$ /backend/web/$1 [L,PT]
RewriteCond %{REQUEST_URI} ^.*$
RewriteRule ^(.*)$ /frontend/web/$1
这是我添加的部分:
RewriteCond %{REQUEST_URI} ^/storeadmin/[a-z]{2}/user/login
RewriteRule ^/storeadmin/([a-z]{2}) %{HTTP_HOST}/store/$1/user/login [R=301,L]
有什么问题吗?我也试过没有%{HTTP_HOST}
。
提前谢谢!
答案 0 :(得分:2)
使用此:
# you were missing a '+' here
Options +FollowSymlinks
RewriteEngine on
AddDefaultCharset UTF-8
# use %1 to target the stored expressions with () from the RewriteCond
# use $1 to target the stored expressions with () from the RewriteRule
# the ? means that the preceeding character may or may not exist
# NC flag means the RewriteRule to be matched in a case-insensitive manner.
RewriteCond %{REQUEST_URI} ^/?storeadmin/([a-z]{2})/user/login/?$ [NC]
RewriteRule ^(.*)$ /store/%1/user/login [NC,R=301,L]