Htaccess mod重写帮助

时间:2012-02-23 07:16:51

标签: .htaccess codeigniter

我想重定向网址:

http://www.mysite.com/invite/YhMck/en

http://www.mysite.com/auth/accept_invite/YhMck/en

可以帮我解决RewiteRule

2 个答案:

答案 0 :(得分:1)

RewriteCond%{HTTP_HOST} ^ mysite.com / invite / YhMck / en RewriteRule(。*)http://www.mysite.com/auth/accept_invite/YhMck/en/ $ 1 [R = 301,L] RewriteEngine On

答案 1 :(得分:0)

将此内容添加到.htaccess

中的documentroot
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_URI} ^/invite
RewriteRule ^invite/([^/]+)/(\w{2})$ auth/accept_invite/$1/$2

来自评论: 这些规则:

RewriteCond $1 !^(index\.php|robots\.txt|images|img|css|js|fonts) 
RewriteRule ^(.*)$ /index.php/$1 [L]

将index.php添加到不以index.php|robots\.txt|images|img|css|js|fonts

开头的每个规则

因此,您的/invite也会被重新写入/index.php/invite...


以相同的顺序尝试此操作

RewriteEngine on
RewriteBase /

RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]

RewriteCond %{REQUEST_URI} ^/invite
RewriteRule ^invite/([^/]+)/(\w{2})$ auth/accept_invite/$1/$2 [L]

RewriteCond $1 !^(auth/|index\.php|robots\.txt|images|img|css|js|fonts) 
RewriteRule ^(.*)$ /index.php/$1 [L]