目前我的网址是: HTTP://www.domain .co.uk / index.php文件/城市/信息/城市名称
我想将其更改为:
HTTP://www.city- name.domain.co.uk/index.php/city/details/city-name
或
HTTP://www.city-name.domain。 co.uk/city/details/city-name
推荐答案把.htaccess文件到HTTP://www.domain.co.uk/文档根目录
Put the .htaccess file into the http ://www.domain.co.uk/ document root
到http://www.city-name.domain.co.uk/index.php/city/details/city-name
To http ://www.city-name.domain.co.uk/index.php/city/details/city-name
RewriteRule ^(.*)/([^/]+)$ www.$2.domain.co.uk/$1/$2 [R=301,L]
到http://www.city-name.domain.co.uk/index.php/city/details/city-name
To http ://www.city-name.domain.co.uk/index.php/city/details/city-name
RewriteRule ^index.php/(.*)/([^/]+)$ www.$2.domain.co.uk/$1/$2 [R=301,L]如果服务器是一样的,上面的重写规则设置这条线prevent重定向循环
If the server is the same, set above RewriteRule this line to prevent redirection loop
RewriteCond %{HTTP_HOST} !^www\.(.*).domain\.co\.uk [NC]
文件的内容例如
File content example
<ifModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} !^www\.(.*).domain\.co\.uk [NC] RewriteRule ^index.php/(.*)/([^/]+)$ www.$2.domain.co.uk/$1/$2 [R=301,L] </IfModule>要排除domain.co.uk(whitout WWW)
To exclude domain.co.uk (whitout www)
<ifModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} !^www\.(.*).domain\.co\.uk [NC] RewriteCond %{HTTP_HOST} !^domain\.co\.uk [NC] RewriteRule ^index.php/(.*)/([^/]+)$ www.$2.domain.co.uk/$1/$2 [R=301,L] </IfModule>更多推荐
codeigniter URL重写像子域网址用的.htaccess
发布评论