How to get ENTIRE URL in a browser without JS?

I have an application that I create in ColdFusion, in which all requests will be executed through the index.cfm file.

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

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

The actual query always uses index.cfm as follows:

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

All this works fine, but now I'm stuck on how I can capture everything that is in the url. None of the CGI variables seem to display a portion of the URL "/ hello / goodbye / howdy".

I tried cgi.path_info and cgi.query_string etc. to no avail ... they are just empty.

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

Dropping the CGI area shows me nothing useful in this regard:

<cfdump var="#cgi#" /> 

Here is 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 also tried using basic Java methods as follows:

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

Without success: (

+4
source share
4 answers
 <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, place the rewrite rules in the same order as above.

+5
source

Check # CGI.REQUEST_URI # - it is undocumented but works

+3
source

Hope this is what you are looking for.

  <cfset link = "http://" & GetHttpRequestData().headers['host'] & GetHttpRequestData().headers['X-REWRITE-URL'] > 
+2
source

I think the easiest way is to view the CGI.PATH_INFO field.

0
source

Source: https://habr.com/ru/post/1396600/


All Articles