简体   繁体   English

使用虚拟主机和URL重写时,请求的URL外观如何?

[英]How will the URL requested look when using vhost and url rewriting?

I have a small system ( Coldfusion8, MySQL 5.0.88 ), which allows users to skin the main website depending on their prefrences. 我有一个小型系统( Coldfusion8, MySQL 5.0.88 ),它使用户可以根据自己的偏好来设置主要网站的外观。

This works all well, except for the URL still being ugly like so: 除URL仍然像这样丑陋外,这一切都很好:

  www.my_site.com/index.cfm?user=123456789

I now want users to have their own URL displayed and have read into vhost (I'm running Apache ) on how to do this. 现在,我希望用户显示自己的URL,并已阅读有关如何执行此操作的vhost (我正在运行Apache )。 I'm changing skins depending on the id provided in the URL. 我将根据URL中提供的ID更改外观。 If I now setup my system to display: 如果现在将系统设置为显示:

  wwww.users_selected_url.com

versus the above, I will have no way to check for the URL ID. 与上述相比,我将无法检查网址ID。 I'm using this ID check a fair bit throughout the application to customize the page layout when rendering the page with Coldfusion. 在使用Coldfusion渲染页面时,我在整个应用程序中使用此ID进行了大量检查以自定义页面布局。

Question: 题:
When will the URL be reformatted? URL何时重新格式化? Will the page being loaded still be requested with the original URL, so Coldfusion can do it's stuff and only the page displayed to the user will be with his customized URL? 是否仍会使用原始URL请求要加载的页面,所以Coldfusion可以做到这一点,只有显示给用户的页面才具有他的自定义URL? How about if I also use URL-rewriting? 如果我还使用URL重写怎么办?

Thanks for some info! 感谢您提供一些信息!

You need to have a vhost setup to accept requests for the wwww.users_selected_url.com host, and the DNS needs to point to your server. 您需要进行虚拟主机设置,以接受对wwww.users_selected_url.com主机的请求,并且DNS需要指向您的服务器。 In the vhost config, you can use the rewrite module to change the URL to /index.cfm?user=123456789 , and this rewriting happens before the URI is handed off to cold fusion. 在vhost配置中,可以使用重写模块将URL更改为/index.cfm?user=123456789 ,并且此重写发生在将URI移交给冷融合之前。 You need to add this to your vhost config: 您需要将此添加到您的vhost配置:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?users_selected_url.com$ [NC]
RewriteRule ^/$ http://www.my_site.com/index.cfm?user=123456789 [L,P]

This uses mod_proxy to proxy the request to http://www.my_site.com/index.cfm?user=123456789 when someone goes to http://www.users_selected_url.com/ in their browser. 这里使用的mod_proxy来代理请求http://www.my_site.com/index.cfm?user=123456789当有人去http://www.users_selected_url.com/在他们的浏览器。

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

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