Hi I'm looking for advice on how to achieve some multiple page functionality for a website builder i've written with the Codeigniter framework.
My initial attempt was creating an "add-on" domain in my host gator c-panel with the corresponding domain name. I then placed an .htaccess redirect to my Code Igniter view URI and it redirects fine. Here is the explanation I have of what is working at the moment.
www.afakecompany.com = the client domain name
www.myserver.com/CI/ = my CI directory
www.afakecompany.com domain register name servers point at my hostgator web hosting.
This hits the add-on domain i've setup called afakecompany.com
Which in turn triggers the .htaccess to redirect, this looks something along the lines of.
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^afakecompany.myserver.com$ [OR]
RewriteCond %{HTTP_HOST} ^afakecompany.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.afakecompany.com$
RewriteRule ^(.*)$ myserver.com/CI/website/view/1 [P,L]
This seemed ok at first, but I have a feeling it is long winded and I can only have one page redirect currently.
Criteria I need to achieve is as follows:
Multiple page option - with the clients domain name showing them the correct url eg..
www.fakecompany.com/contact showing in the browser but actually grabbing the content from myserver.com/CI/website/view/1/contact ('not sure how ci will route this stuff yet')
Scaleability - Is having a new add-on domain for each new website a bad idea? It seems it to me. Also if I had to relocate hosting or modify something in all the .htaccess files it would be a nightmare
I am new to web development so I apologize for any face palming that may have occurred on account of my noobness. So I ask thee.. How could I achieve this/do it better?
You should probably look at getting a reseller account, since any home-brewed solution might pose a security risk if you implement it incorrectly across multiple client's accounts. A reseller account is nice because you basically sell access to your server resources (bandwidth, space, etc.) but the client's accounts are isolated.
Related
I've coded a website myself (html, css, a bit of jquery/javascript and php, with a database connection). It's in essence just a simple portfolio with text, a carousel of photos/designs/videos and some pdf files. So, no users are involved except a simple login for myself to upload additional photos or designs. These photos, designs and videos are saved in a simple database.
Whenever I go to my website in e.g. a safari browser, safari let's me know that the website is 'not safe' because I don't have a SSL certificate or .htaccess file. (So, my website is http://example.com and not https://example.com). However, it works perfectly regardless of the 'not safe' notification in the browser bar.
I've contacted the hosting company and they told me to create a .htaccess file and place it in the public_html folder.
This is the content of that file:
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
SetEnvIf X-Forwarded-Proto "https" HTTPS=on
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
However, when I add this to my public_html folder, my website simply doesn't work. When I go to example.com it correctly redirects to https://example.com, but I get this notification:
Not Found
The requested URL was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request.
When I delete the .htaccess file, it works again (but is unsafe according to my browser).
The hosting company responded with: "we are not website builders so we can't help you with this", so I'm at a loss on how to fix this. Hence this post.
How do I fix this, without a cms to depend on?
The error is not on the code, it depend on apache configuration, if you have access to the server ssh, look this tool : https://certbot.eff.org/. if you're not, the hosting compagny have to resolve you're problem.
Been struggling with this problem for a while now.
We have a basic online app which you can access at say
app.domain.co/signup?user=onlinestore
onlinestore is the username of the account.
We want each user to get their own subdomain that they can use the app from.
In this case the subdomain would be onlinestore.domain.co/signup and it would show them the contents as if they were here: app.domain.co/signup?user=onlinestore.
Now as well as that subdomain mirroring the login pages, when they login I would like for all of the pages inside of the app to be able to use the subdomain as well. Ideally I don't want the user to see the app.domain.co domain at all, just their personalised domain. Theres quite a number of pages inside the app so im not sure if theres a simple way for them all to be accessible from any subdomain (if logged in ofc).
Examples:
onlinestore.domain.co will become app.domain.co/signup?user=onlinestore
onlinestore.domain.co/payments will become app.domain.co/payments?user=onlinestore
onlinestore.domain.co/contact will become app.domain.co/contact?user=onlinestore
Current HTACCESS File (in the wildcard subdomain)
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.domain.co$ [NC]
RewriteCond %{HTTP_HOST} ^([^.]+).domain.co
RewriteRule ^$ https://app.domain.co/signup/?user=%1 [L]
We've created a wildcard subdomain but it's not working with https, and it's doing a full redirection as opposed to a rewrite, I'm still on shared hosting so I'm not sure if I might have some restraints due to this.
Is there a simple way to do this? I don’t want the users to see the app.domain path at all, just their custom subdomain path.
I've made a new website for a client who has an intranet integrated into their old website.
The new website is currently on a different server, but when the domain A records point to the new server, the old site (and intranet) will obviously not be accessible, but I need to keep their intranet active. The path to their intranet is: abc.com/intranet
Is there a way to have URL path direct to the old server? For example:
abc.com - new website loads on new server
abc.com/intranet - old website loads on older server
If it's not possible, I suppose I'm looking at creating a sub-domain on abc.com for the intranet. Any thoughts are appreciated.
You need to use an Apache RewriteRule using mod_rewrite. This can be placed in an .htaccess file on your server’s root or it can be placed directly into your Apache config file.
If you want to redirect example.com to example.com/intranet, then this is the Apache RewriteRule that should work for your needs:
RewriteEngine on
RewriteRule ^(.*)$ /intranet [L,R=301]
This will grab any URL on the site this RewriteRule is placed on & redirect them to /intranet. That /intranet can also be a full URL such as this example below:
RewriteEngine on
RewriteRule ^(.*)$ http://example.com/intranet [L,R=301]
EDIT: Upon rereading your question, I am not 100% sure the answer above works for you as-is. So I think if you are describing how to point one URL path from one server to another, you would do this. This gets placed on the new server:
RewriteEngine on
RewriteRule ^/intranet(.*)$ http://old_example.com/intranet [L,R=301]
That would grab any URL coming from new_example.com/intranet and redirect it to old_example.com/intranet.
ANOTHER EDIT: Since the original poster indicates the server will have the IP fully changed, then a subdomain for the old server is the best way to go. You can’t redirect content on one domain the way you describe if you switch the domains fully to different IP. Both servers need to be active with an active—but different—domain name for what you want to happen.
abc.com/intranet is a path in the virtual file system exposed by your web server, so is not possible to serve the content from different web server. You have 2 options here.
Put a reverse proxy in front of both servers and get the content from server A or B based on the original client request.
As you said, create a subdomain and also redirect /intranet to the new subdomain.
Hope this help!
I have tested my website on my localhost and it is working fine and all the views/controllers and models are tested.
So I thought I would put it on my webserver and test it there, the website displays however when doing functions like
For example registering or loging into the website does not work:
I checked in firebug it is saying
500 Internal server error
Here is my site, please could you have a browse through the pages , even try registering if you like.
Another thing I noticed on the failed pages is that my favicon is changing to the root domains favicon.
Here is my actual website, its in a sub domain.
Could it be my htacces
Here is the code in it:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
I dont understand why It works on my localhost but not on a dedicated server.
They were both Apache windows servers.
Thanks, for your time.
I think the problem is with your routes. All your pages are with in the domain
http://www.iiios.eu/midas/site/register
But on registering or login it goes to
http://www.iiios.eu/midas/register
without the site in the middle and CI doesnt know how to transfer control to the route. You might wanna check your forms open and action atr for register and login form.
Update
This is your form tag. Check whether you have the method create_member on register class which is in midas directory. My guess is that you have accidentally missed the site there.
I think it should have been
"http://www.iiios.eu/midas/site/register/create_member"
This might be a problem with the routing, see if the referencing to the routes, like when registering, are correct or if you defined routes in the config.php. Is the base_url() defined correctly? Also on the homepage in the sidebar you reference a non-object property.
my website has a log in by open id feature. When a user logs in for the first time using his/ her openid they are redirected to a create account page. I noticed just recently that one user when logged in using her google account created an account for the first time. However when she tried to log in again using the same google account - she was faced with creating a new account again. I checked the db and saw that although she used the same google account - the open ID urls which were retrieved are different?
EDIT===================
Thanks Kobi for the information - the issue is that I need to set up my website so it always opens with www prepended to it i.e. http://www.mysite.com and NOT http://mysite.com
Owing to this subtle difference google OpenID recognises the two urls as different urls!!! Help please
I realised its an htaccess thing however I googled a bit and found these htaccess commands:
RewriteCond %{HTTP_HOST} ^site.com [NC]
RewriteRule (.*) http://www.site.com/$1 [L,R=301]
However the problem is that when I use this in my htaccess it does forward and ensure the link reads as www.site.com however it messed up all the javascript links - actually I'm using url rewriting here as well... my whole htaccessfile is somewhat like this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
AddType text/css .css
inclusion of the two lines messes up the url rewriting :( what do I do here
======================
Uh never mind I figured it out :) I was putting the two rewrite url lines at the end thus somehow overriding the other rewrite rules - putting them in the beginning fixed it :) thanks anyway
Google gives different URLs for different domains.
It is possible your user used a different URL each time to log in? Even www on the start of the url can change the code Google returns.