简体   繁体   English

转发域并从URL中删除端口号

[英]forward the domain and remove the port number from the URL

With this. 有了这个。 .htaccess code , the domain is forwarded to port 8000. The problem is the port number in the URL. .htaccess代码 ,该域将转发到端口8000。问题是URL中的端口号。

RewriteEngine On RewriteEngine开

RewriteCond %{HTTP_HOST} ^my\.subdomain\.com$ [NC]
RewriteRule ^(.*)$ http://my.subdomain.com:8000/$1 [R=301]

I am now looking for a way to forward the domain and remove the port number from the URL. 我现在正在寻找一种转发域并从URL中删除端口号的方法。 There must be a solution with PHP or. 必须使用PHP或解决方案。 .htaccess be. .htaccess是。 Web server and all of my domains are running on port 80 and on port number 8000 is running an application. Web服务器和我的所有域都在端口80上运行,而端口号8000在运行应用程序。

Edit and modify the httpd.conf file does not work. 编辑和修改httpd.conf文件不起作用。 It is Overridden again. 再次被覆盖。 :-( My Hoster confirmed me that :-(我的房东确认我

Thank you! 谢谢!

Proxypass imperatives are available in Apache as well as ngnix. 在Apache和ngnix中都可以使用Proxypass命令。 I recently answered a different question with the same solution to your problem here: https://serverfault.com/q/448733/261031 and on my own website here: http://joshwieder.blogspot.com/2014/12/apache-virtualhost-proxy-config-nodejs-tomcat.html but I will also reproduce the example here with the port numbers you have specified: 我最近在这里用您的问题的相同解决方案回答了一个不同的问题: https//serverfault.com/q/448733/261031,并在我自己的网站上: http : //joshwieder.blogspot.com/2014/12/apache -virtualhost-proxy-config-nodejs-tomcat.html,但我还将在此处使用您指定的端口号重现示例:

<VirtualHost *:80>
    ServerName my.subdomain.com
    ProxyRequests Off
    ProxyPreserveHost On
    <Proxy *>
        AddDefaultCharset Off
        Order deny,allow
        Allow from all
    </Proxy>
    ProxyPass / http://my.subdomain.com:8000/
    ProxyPassReverse / http://my.subdomain.com:8000/
</VirtualHost>

Note that with this configuration you will be able to access your site both with and without port number 8000 as a suffix. 请注意,使用此配置,无论有没有端口号8000作为后缀,您都可以访问您的站点。

Try Nginx server its quit easy! 试试Nginx服务器,退出容易!

bellow is its demo config. 下面是它的演示配置。

server {
listen       80;  
server_name  blog.ramki.com;  
rewrite_log  on;
error_log    logs/error_ramki.log   notice;
rewrite   ^/(.*)$   /department1/$1;   
location / {
proxy_pass http://127.0.0.1:8282;  
}
}

for further reference please visit This 有关更多参考,请访问

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

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