简体   繁体   中英

how to host two sites?

UPDATE: OK, Tesla (user) solved most of this with a php snippet (down below), so my remaining question is what to do with this piece of code in public_html .htaccess:

# BEGIN WordPress
  <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
  </IfModule>

 # END WordPress

Index.php in public_html is currently what loads wordpress.

Index2.php is my new site. I so badly want to rename it index.php so I can launch the new site. But I'm a bit confused as to what goes where.


My (original) question: I want it so that when you go to www.mysite.com, if you're using webkit it'll load the webkit-only site. But if you're running IE or Opera or whatever else, you get taken to www.mysite.com/wordpress

I'm losing my mind trying to figure this out.

I've posted about this elsewhere, and gotten some good answers, but I'm still running up against a brick wall with this.

I have a wordpress site installed, working perfectly, but I hate wordpress, mostly because it reloads the whole site on every click, plus it feels "heavy" in general.

Anyway I built a new site, but I suck at cross-browser friendliness so for the time being it's a webkit-only site, which I'm actually totally fine with that. It's a very slick one-page site that loads in various associated pages via ajax. It has tons of animations, smooth-scrolling, etc. and I'm really &*^% happy with it.

So again, I want it so that when you go to www.mysite.com, if you're using webkit it'll load the new webkit-only site. But if you're running IE or Opera or whatever else, you get taken to www.mysite.com/wordpress

I keep trying to figure this out but I'm gonna have a heart attack doing it. I keep making mistakes (I'm not a PHP programmer). I hate doing server-level stuff because it means I gotta take the site offline, and then play around with what feels like life-or-death.

What I need is a step-by-step walkthrough on precisely what to do, every step of the way, until the goal of having www.mysite.com (webkit-only) plus www.mysite.com/wordpress (for all other visitors) is achieved.

Someone from this site gave me this snippet, and it works great:

(Placed in root index.php)

<!DOCTYPE html>
<?php   

$navigator_user_agent = ' ' . strtolower($_SERVER['HTTP_USER_AGENT']);
if (strpos($navigator_user_agent, "webkit")) { 
?>

//page goes here (html, jquery, content etc.) Then, all the way at the bottom:

<?php
} else {

    header('Location: www.mysite.com/wordpress'); //redirects user to the given location
  }
?>

It works like a charm. Webkit gets the new site, and opera, IE, etc., end up getting sent to that URL.

The problem is wordpress also wants to use a file in root called index.php.

The next problem is how to modify the htaccess correctly, so that it doesn't conflict with what I'm trying to do.

Look, if this is too much to ask, I'm perfectly willing to pay by the hour. I just don't know anyone, but if someone qualified wants to get on Skype and help me do this, perhaps that would be even better than having an online discussion.

Pretend your site is this

<html>
  <head>
    //stuff here
  </head>
  <body>
    //stuff here
  </body>
</html>

Add to the top of that file the following

<?php   
if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "webkit") === false) { 
  header('Location: www.mysite.com/wordpress'); //redirects user to the given location
  exit;
}
?>

So now you have

<?php   
if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "webkit") === false) { 
  header('Location: www.mysite.com/wordpress'); //redirects user to the given location
  exit;
}
?>

<html>
  <head>
    //stuff here
  </head>
  <body>
    //stuff here
  </body>
</html>

Save this file as index.php in public_html.

Your wordpress site should be moved to public_html/wordpress

Everything should work after that

EDIT: As for your updated question, move the .htaccess to public_html/wordpress as well, all thats in there is for wordpress. In the public_html folder you can create a blank .htaccess or just have none for now untill you need one for mysite.com.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM