[英]How can I redirect an incoming URL only if it contains a certain string?
We currently have our company's image hosting site on our own server for the sake of performance. 为了提高性能,我们目前在自己的服务器上拥有公司的图像托管站点。 We want to separate the front end of the site (generic pages) from the database-driven backend (where all users upload and view images) so that the front end can be hosted off-site and be enhanced for SEO while the backend stays local on our dedicated server for better performance.
我们希望将站点的前端(通用页面)与数据库驱动的后端(所有用户都在其中上传和查看图像)分开,以便可以将后端托管在非现场并针对SEO进行增强,同时后端保持本地状态在我们专用的服务器上以获得更好的性能。
With that in mind, I plan to point the main domain to the offsite hosted pages. 考虑到这一点,我计划将主域指向非现场托管页面。 Currently our clients have urls pointing to jobs on our server which we cannot change.
当前,我们的客户有指向我们服务器上无法更改的作业的url。 So, we want to be able to redirect any urls that have a certain string (referring to the backend) to our local server's static IP address.
因此,我们希望能够将任何具有特定字符串(指后端)的url重定向到我们本地服务器的静态IP地址。
Example: 例:
www.domain.com/aboutus/
← Does not contain target string, so no change www.domain.com/aboutus/
不包含目标字符串,因此没有更改
www.domain.com/TARGETSTRING/something/something/
← Has target string, so it will point to our static local IP address, ie http://294.34.21.5/TARGETSTRING/something/something
www.domain.com/TARGETSTRING/something/something/
具有目标字符串,因此它将指向我们的静态本地IP地址,即http://294.34.21.5/TARGETSTRING/something/something
One other note: Currently the whole site is running on ColdFusion on IIS. 另一个注意事项:目前,整个站点都在IIS的ColdFusion上运行。 With the new setup, the backend (local server) will stay the same, but the front end will be in Wordpress.
使用新设置,后端(本地服务器)将保持不变,但前端将位于Wordpress中。 So I imagine that the
htaccess
file may come into play, but not with the usual RewriteRule mod. 因此,我认为
htaccess
文件可能会起作用,但不能使用通常的RewriteRule mod。
You should be able to handle this in PHP by checking the $_SERVER var that is most applicable. 您应该能够通过检查最适用的$ _SERVER var在PHP中进行处理。
http://php.net/manual/en/reserved.variables.server.php http://php.net/manual/en/reserved.variables.server.php
You can then set a conditional and, if (say a regex pattern match is true) then perform a server-side redirect with location
. 然后,您可以设置条件,如果(例如,正则表达式模式匹配为true),则使用
location
执行服务器端重定向。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.