简体   繁体   English

在子域上创建网站的测试版

[英]Creating a beta version of site on subdomain

I have a website that I have been working on for a while. 我有一个已经工作了一段时间的网站。 All this time I have been editing the live website files on the web server for my development. 一直以来,我一直在编辑Web服务器上的实时网站文件以进行开发。 I finally realized that it was stupid to edit the live site. 我终于意识到编辑实时站点是愚蠢的。 My "quick" solution is to copy everything from example.com to beta.example.com. 我的“快速”解决方案是将所有内容从example.com复制到beta.example.com。 I will edit the beta subdomain and when I have a feature to release, I will copy and replace the existing code on the example.com site. 我将编辑beta子域,当我要发布功能时,我将复制并替换example.com网站上的现有代码。 Great. 大。

That would be great if I could get it to work. 如果我能使它工作,那将是很棒的。 I'm having troubles with my .htaccess files for both domains and URL rewriting. 我的域名和URL重写的.htaccess文件遇到问题。

For my example.com site, I use a .htaccess like so: (there are only a handful of pages on my site) 对于我的example.com网站,我使用.htaccess像这样:(我的网站上只有很少的页面)

RewriteEngine On

RewriteCond %{HTTP_HOST} !^example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301]

RewriteCond %{REQUEST_URI} ^/recent
RewriteRule ^ recent.php [NC,L]

RewriteCond %{REQUEST_URI} ^/about
RewriteRule ^ about.php [NC,L]

RewriteCond %{REQUEST_URI} ^/category/(.*)/(.*)
RewriteRule ^ category.php?id=%1&name=%2 [NC,L]

RewriteCond %{REQUEST_URI} ^/category/(.*)
RewriteRule ^ category.php?id=%1 [NC,L]

The problem with the beta.example.com site is that it always redirects to just regular example.com. beta.example.com网站的问题在于,它始终只能重定向到常规example.com。 It removes the beta subdomain. 它删除了beta子域。

What is the proper .htaccess code to get subdomain sites separate from non-subdomains? 使子域站点与非子域分开的正确的.htaccess代码是什么?

You have to configure settings for beta.example.com on your server. 您必须在服务器上配置beta.example.com的设置。 Setting like DNS in the domain account and if you are using windows(IIS)/linux(Apache) server then configure it same way as you have configured example.com. 在域帐户中设置类似DNS的设置,如果您使用的是Windows(IIS)/ linux(Apache)服务器,请按照配置example.com的相同方式进行配置。 If you are using shared hosting then you must have CPanel for your website. 如果您使用共享主机,则您的网站必须具有CPanel。 then create new directory through that and point the beta.exapmle.com to that directory. 然后通过该目录创建新目录,并将beta.exapmle.com指向该目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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