douza19870617 2014-06-30 10:58
浏览 33

如何使用htaccess在codeigniter中创建动态子域

am using codeigniter, I want to set up .htaccess to make dynamic subdomains. And I cannot figure out how. I am trying to create custom domain names using .htaccess

Currently my URL looks like this:

http://www.example.com/public/stores/shop/products

I need it to look like this:

http://www.shop.example.com/public/stores/products

but it throws a 404?

stores - controller name, shop - dynamic name

The problem is that each shop should get a sub-domain automatically.Would be great if you could share the work around for the code & the .htaccess

I tried this code:

<IfModule mod_rewrite.c>
   Options +FollowSymLinks
   Options +Indexes
   RewriteEngine On
   RewriteBase /

   RewriteCond %{HTTP_HOST} !www.example.com$ [NC]
   RewriteCond %{REQUEST_URI} ^/$
   RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-_]+).example.com [NC]
   RewriteRule (.*) /index.php/controller/function/%2 [P]

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

Thanks in advance.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计