codeigniter URL重写像子域网址用的.htaccess

编程入门 行业动态 更新时间:2024-10-28 11:33:50
本文介绍了codeigniter URL重写像子域网址用的.htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

目前我的网址是: 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

本文发布于:2023-10-31 17:32:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546784.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   域网   codeigniter   URL   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!