0

Im building a kind of small CMS wich needs to be accessed from multiple Domains.

eg.

CMS is installed on www.maindomain.com and needs to be accessed by: domain1.com domain2.com ...

if domain1.com is called, it must display the content from maindomain.com/index.php?web=domain1 domain1.com/somepath... --> maindomain.com/index.php?web=domain1&path=somepath..

I don't want to copy my CMS to every domain so the domains need to access the CMS from maindomain.com.

My first try was to just include the main CMS via PHP require() by using an absolute path.. this causes several problems because I would need to chance the server config(php.ini allow_url_include) wich might not work on a small webspace without root access. And if maindomain.com uses require() without absolute paths, the file can't be found..

The only solution I found so far is to create a reverse proxy redirect from domain1.com to maindomain.com/index.php?web=domain1 But this might not work with all Domain resellers / might not be good for search engines..

I'm open to any solutions that would solve the problem.. but it should be (if possible) ok for SEO + work on servers without editing configs..

Thanks

__ edit: really? no one had this / a similar problem before?

1 Answers1

0
RewriteEngine On

RewriteBase /

RewriteCond %{QUERY_STRING} !^.*web=
RewriteCond %{HTTP_HOST} ^([-A-Za-z0-9]+\.)*([-A-Za-z0-9]+)\.[-A-Za-z0-9]+$
RewriteRule index\.php$ http://maindomain.com/index.php?web=%2 [P]

Put this in the htaccess. It should work.

Tobias
  • 653
  • 4
  • 12
  • I don't really get what this should do but seems not like a solution for my problem.. looks like basic rewrite within a domain.. I tried this `RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*) http://maindomain.com/index.php?web=domain1&path=$1 [QSA,L]` but it only redirects to the main domain.. – northernlights Jul 28 '15 at 06:20
  • Look in my edit. Every traffic from any subdomain Rewrite to http://maindomain.com/index.php?web=sudomain. – Tobias Jul 28 '15 at 06:29
  • ah ok now i get it.. Problem is that my "non maindomains" aren't sub domains.. they are completely different domains.. – northernlights Jul 28 '15 at 06:41
  • It should also work with completely different Domains. But the htaccess must be in the directory where the domain is solve. – Tobias Jul 28 '15 at 07:20
  • Seems like it's pretty close to my attempt.. but sandly this wont work.. [How to set up proxy in .htaccess](http://stackoverflow.com/questions/19205092/how-to-set-up-proxy-in-htaccess) – northernlights Jul 28 '15 at 11:15