Forum Moderators: phranque

Message Too Old, No Replies

how to find request url in .htaccess

how to find request url in .htaccess

         

camsuresh

2:35 am on Mar 30, 2009 (gmt 0)

10+ Year Member



 
RewriteEngine On

RewriteRule ^add_ads.php$ - [L]
RewriteRule \.(php多tm多tml)$ add_ads.php?file=%{SCRIPT_FILENAME} [L]

{SCRIPT_FILENAME} gives local requested path. But I need to find the remote server path. Like http://currentdomain.com/<requested_file> instead of /var/www/html/index.php

Looking for help!

[edited by: jdMorgan at 5:22 pm (utc) on Mar. 30, 2009]
[edit reason] De-linked, [ code ] formatting corrected. [/edit]

Caterham

10:13 am on Mar 30, 2009 (gmt 0)

10+ Year Member



You're looking for
REQUEST_URI

jdMorgan

5:28 pm on Mar 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




RewriteEngine on
#
RewriteRule ^add_ads\.php$ - [L]
RewriteRule \.(php多tm多tml)$ add_ads.php?file=%{REQUEST_URI} [L]

-or-

RewriteEngine on
#
RewriteRule ^add_ads\.php$ - [L]
RewriteRule ^(.+\.(php多tm多tml))$ add_ads.php?file=$1 [L]

-or-

RewriteEngine on
#
RewriteCond $1 !^add_ads\.php$
RewriteRule ^(.+\.(php多tm多tml))$ add_ads.php?file=$1 [L]

This final version allows you to have other rules which affect "add_ads.php" requests in your file following this rule, unlike the first two examples, which would stop mod_rewrite processing completely if the requested URL-path was for "add_ads.php"

Jim