如何获得完整的URL在没有JS浏览器中看到的?如何获得、器中、完整、URL

2023-09-02 00:51:43 作者:长街旧人.

我有一个应用程序我建立ColdFusion中,从而使所有的请求将通过index.cfm文件中运行。

我有一个重写URL .htaccess文件。因此,举例来说,如果我写的:

http://domain.com/hello/goodbye/howdy

在实际的请求始终使用index.cfm像这样:

http://domain.com/index.cfm/hello/goodbye/howdy

用js获取浏览器的url,然后如何把这个url传给php

这一切的伟大工程,但现在我只能和我怎么能抓住一切是在URL中。不是CGI变量似乎并不输出/你好/再见/你好的URL的一部分。

我已经试过cgi.path_info和cgi.query_string等无济于事......他们只是空白。

我需要抓住的一切,域名后,做的东西,在CF它。我知道这是可能的JS,但我真的需要这个服务器上。

转储CGI范围显示我什么有用的在这方面的:

 < cfdump VAR =#CGI#/>
 

下面是我的参考htaccess文件:

 < IfModule mod_rewrite.c>

RewriteEngine叙述上

的RewriteBase /
重写规则^指数 .CFM $  -  [L]
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则。 /index.cfm [L]

的RewriteCond%{HTTP_HOST}!^ WWW 。
的RewriteCond%{HTTP_HOST}!^([^ 。] +)。域 .COM
(。*)重写规则^ $ HTTP://www.% {HTTP_HOST} / $ 1 [R = 301,L]

< / IfModule>
 

感谢。

编辑:

作为一个额外的说明,我也试着底层的Java方法就像这样:

 < cfdump VAR =#getPageContext()调用getRequest()getContextPath()#/>
< cfdump VAR =#getPageContext()调用getRequest()getRequestURL()#/>
< cfdump VAR =#getPageContext()调用getRequest()getQueryString()#/>
 

要没有成功:(

解决方案

 < IfModule mod_rewrite.c>

RewriteEngine叙述上
的RewriteBase /

重写规则^指数 .CFM $  -  [L]

的RewriteCond%{HTTP_HOST}!^ WWW 。
的RewriteCond%{HTTP_HOST}!^([^ 。] +)。域 .COM
(。*)重写规则^ $ HTTP://www.% {HTTP_HOST} / $ 1 [R = 301,L]

的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{} REQUEST_FILENAME!-l

#Change存在的位置:
重写规则^(。*)$ /index.cfm?actualuri=$1 [L,QSA]

< / IfModule>
 

cgi.query_string 现在。它应该有 actualuri = /的/路径/发送。 此外,把作为把上述相同的顺序重写规则。

I have an application I'm building in ColdFusion, whereby all requests will run through the index.cfm file.

I have a .htaccess file that rewrites the URL. So, for example...if I write:

http://domain.com/hello/goodbye/howdy

The actual request always uses index.cfm like so:

http://domain.com/index.cfm/hello/goodbye/howdy

This all works great, but now I'm stuck with how I can grab everything that is in the URL. Not one of the CGI variables don't seem to output the "/hello/goodbye/howdy" part of the URL.

I have tried cgi.path_info and cgi.query_string etc to no avail...they're just blank.

I need to grab everything that comes after the domain name, and do stuff in CF with it. I know it's possible in JS, but I really need this on the server.

Dumping the CGI scope shows me nothing useful in this regard:

<cfdump var="#cgi#" />

Here's my htaccess file for reference:

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /
RewriteRule ^index.cfm$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.cfm [L]

RewriteCond %{HTTP_HOST} !^www.
RewriteCond %{HTTP_HOST} !^([^.]+).domain.com
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

</IfModule>

Thanks.

EDIT:

As an additional note, I've also tried the underlying Java methods like so:

<cfdump var="#getPageContext().getRequest().getContextPath()#" />
<cfdump var="#getPageContext().getRequest().getRequestURL()#" />
<cfdump var="#getPageContext().getRequest().getQueryString()#" />

To no success :(

解决方案

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /

RewriteRule ^index.cfm$ - [L]

RewriteCond %{HTTP_HOST} !^www.
RewriteCond %{HTTP_HOST} !^([^.]+).domain.com
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

#Change exists here:
RewriteRule ^(.*)$ /index.cfm?actualuri=$1 [L,QSA]

</IfModule>

try cgi.query_string now. It should have actualuri=/the/path/sent. Also, put the rewrite rules in the same order as put above.