How can I implement dynamic subdomains in codeigniter
with .htaccess
?
相关问题
- Backbone.js PushState routes .htaccess only workin
- Stop .htaccess redirect with query string
- .htaccess rule, redirecting old unexistent address
- What is this file in .htaccess?
- If statements in .htaccess files, to enable passwo
相关文章
- mod_rewrite only on GET
- Multiple htaccess rewrite rule
- AWS ALB redirect to https
- rewrite urls for product name
- Codeigniter remove index.php - htaccess localhost
- How can I build the regex to match a string NOT co
- Relative paths from file for img, a and header
- How to change the name of the directory in url in
this code is working for my site, you can move your site into your other domain or folder ( whatever you want ).
Make sure that subdomains are enabled on your site. When you enter test.yoursite.com it should take you to the welcome page of your site. If instead it gives DNS lookup error then it means subdomains is not enabled on your site.
To enable subdomains on your site add
*.yoursite.com
entry to the DNS Zone records.Second insert the following code in your
.htaccess
file and replaceyoursite
appropriately.Add more rules, if necessary, for handling auth system or subdomains. I know I did for my site to get pretty URIs.
Important Note:
I found that by default the subdomain URIs work very well with codeigniter without any of the above rules. You can access all of your site with
test.yoursite.com/#
URI instead ofwww.yoursite.com/#
. But the URIs are not pretty and there would be more than one way to access a URI.So if you use the above rules it will give you pretty URIs and, more importantly, will give you unique URIs. So if you use the above rules you will only get one URI for the signup page and that is
http://yoursite.com/signup
.This rule handles the subdomains