我有一个基于Apache2.4的www.main.com托管和多个子域,如
www.sub1.main.com,www.sub2.main.com,。
文件夹结构是
/home/main/.htaccess + project files and subdomain folders like:
/home/public-html/main/sub1.main.com/.htaccess
/home/public-html/main/sub1/.htaccess + project1 files
/home/public-html/main/sub2/.htaccess + project2 files等。
子域是基于不同技术的单独项目。
基于AngularJS的/home/main/网站具有标准的角.httaccess配置:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /index.html [NC,L]我希望在.htaccsess中有另一个sub.main.com配置,如下所示:
RewriteEngine On
RewriteRule ^$ http://127.0.0.1:3000/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^api$ http://127.0.0.1:3000/$1 [P,L]代理应该将我的Apache流量重定向到我的nodejs服务器。
在某个时候,我的子域重定向不起作用。这只是来自主文件夹的作品。
所以我有三个问题:
这里- /home/public-html/main/sub1.main.com/.htaccess或这里-/home/public-html/main/sub1/..htaccess+ project1文件
这是一个共享主机,对apache配置的访问权限有限。我只能使用.httaccess方式,我没有更改虚拟主机的权限,所以请只提供.httaccess解决方案。
上面的代码片段都不起作用,也不会重定向任何节点,而是只从主/主文件夹,而不是从子域。
我需要每个子域的特殊.htaccess来托管多个项目。
发布于 2019-03-12 11:39:07
我为任何想要在共享主机上使用nodeJS的人找到了解决方案:
放到/home/main/www/ .htaccess下面:
RewriteEngine on
RewriteOptions inherit
RewriteCond %{HTTP_HOST} ^main\.org$ [OR]
RewriteCond %{HTTP_HOST} ^www\.main\.org$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/.+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^/?$ "http\:\/\/angular\.main\.org\/" [R=301,L]
RewriteBase /
RewriteCond %{REQUEST_URI} !^/node/
# Rewrites all URLS node.main to node server
RewriteCond %{HTTP_HOST} ^(www\.)?node.main\.
# Redirect to node server
RewriteRule ^(.*)$ http://127.0.0.1:3000/$1 [P, L]
内部/家庭/主/www/角放置.htaccess类似:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /index.html [NC,L]
我们不需要节点文件夹中的任何.htaccess,我希望它能对有同样问题的人有所帮助。
https://stackoverflow.com/questions/55119245
复制相似问题