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.
Related
I have this site lets say (mydomain.com) that has been running for quite a while, we decided that we would like to build a blog too, naturally we wanted to use wordpress(great for blogs). We wanted to use a subdomain blog.mydomain.com
mydomain.com uses cloudflare and the site itself is build with Laravel, our project is placed in public_html/coolproject because of laravel we had to make these changes to our htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ coolproject/public/$1 [L]
</IfModule>
After deciding to create a blog we naturally created A record in cloudflare pointing to our ip just like the main domain. (blog.mydomain.com)
The issue is following: every time we try to access blog.mydomain.com it shows mydomain.com content.
I think that the issue lies in
RewriteRule ^(.*)$ coolproject/public/$1 [L]
because every request is pointed to coolproject/public folder.
I am not very good with htaccess and don't know all of it's possibilities, I am wondering if it's possible to edit this rule so subdomains wouldn't be affected in this scenario and how.
goal is for blog.mydomain.com to show public_html/mycoolblog contents.
I want to be able to redirect folders and subfolders (all html) to another server with different folders (php)
I have a domain with DNS redirects Cname and A field pointing the domiain (that has not changed) to new website using php.
So, I want to do the following as an example.
On the old server
http://www.domain.co.uk/folder1/subfolder1/page.html
to go to
New server
http://www.domain.co.uk/folder3/
The domain used to point at the htdocs folder on the first server but now using CNAME and an A field it points to the second (new) server
Can I just redirect bulk folders to the new folders?
Hope this makes sense
Richard
You can redirect bulk folders.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.otherdomain.com/$1 [R=301,L]
This is a simple code that redirects ftm domain.com to otherdomain.com. But if you want to change folder1/folder2 to folder3, well.... just think you could you possibly shrink that to a simple rule? I think below 50 pages you better off wiriting 301 redirects line by line. Otherwise, no short way.
Lets say i have wildcard subdomains on an external domain, can be anything like
demo.site1.com
blah.site1.com
and have directories like these on an external websites
external.com/websites/demo.site1.com
external.com/websites/blah.site1.com
and i want to make it so that all requests for lets say demo.site1.com should rewrite to
external.com/websites/demo.site1.com if the subdirectory matches demo.site1.com
NO REDIRECTION, I MUST KEEP THE URL THE SAME...
I have to do this for multiple subdomains with the same kind of subdirectories.
Is it possible to do?? if not is it possible without matching???
I read the apache .htaccess docs over and over for the past 12 hours and can't seem to
figure out a way how to do it.
Your help will mean alot to me...
You should configure Your domain in domain administration panel to point at this addresses.
If You don't have access to them use iframe, but as far I know .htaccess doesn't provide this kind of functionality.
try this. put it inside htaccess on site1.com document root. it work only if both domain has permission to access together
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)\.site1.com/(.*)$
RewriteRule ^(.*)$ external.com/websites/$1.site1.com/$2 [L]
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.
I've got a Zend Framework application that has a http://dashboard.domain.tld subdomain, and the rest of the application resides at http://domain.tld. I'd like to keep all the app code in the parent domain however, so I need to redirect the subdomain to the parent domain somehow.
I've got all the dashboard code in a Zend Module and I've set my .htaccess set up in the root subdomain folder like so:
RewriteEngine On
RewriteRule ^(.*)$ http://domain.tld/dashboard/$1 [NC,NS,L]
The redirect is working just fine, except that the redirected URL is showing up in the address bar, rather than the original URL. I need the URL to remain as it was entered by the user.
I've taken a look at .htaccess redirect without changing address bar and other similar questions but thus far nothing is helping.
Would appreciate any help!
You should try [P] flag in your dashboard.domain.tld configuration.
RewriteEngine on
RewriteBase /
RewriteRule (.*) http://domain.tld/dashboard/$1 [P,QSA,L]