Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite not working

mod_rewrite not working

         

umakanth

4:34 pm on Jul 18, 2005 (gmt 0)

10+ Year Member



I have following rewrite rule but it does not work. Any ideas?

RewriteCond %{REMOTE_ADDR} ^161.127.48.105$
RewriteRule ^/cc2k_login$.startup$ /cust_credit_app$.startup$1 [PT]

jdMorgan

7:27 pm on Jul 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is your code in .htaccess. If so, be aware that the URL-path to the current .htaccess file's directory location will be stripped. If, for example, your .htaccess file is located in example.com/.htaccess, then the leading slash will be stripped from the url-path "seen" by RewriteRule. If it is located in example.com/dir/.htaccess, then /dir/ will be stripped. That's why .htaccess is called a "per-directory configuration file."

In addition, you should escape literal characters in your patterns which otherwise will be taken as regular-expressions operators, and add an [L] flag to any rule that, if applied, is the last thing you need to execute before serving content.

Applying this info to your rule, we get:


RewriteCond %{REMOTE_ADDR} ^161\.127\.48\.105$
RewriteRule ^cc2k_login\.startup$ /cust_credit_app$.startup$1 [PT,L]

If you actually have a "$" character after "cc2k_login" (I wasn't sure), then the pattern becomes
^cc2k_login\$\.startup$

Jim

umakanth

7:36 pm on Jul 18, 2005 (gmt 0)

10+ Year Member



Thanks Jim, The mod_rewrite instructions are in httpd.conf file not in .htaccess

I tried using escape characters, still does not work...

RewriteCond %{REMOTE_ADDR} ^161\.127\.48\.105$
RewriteRule ^cc2k_login\$\.startup$ /cust_credit_app\$\.startup$1 [PT,L]

logi

9:46 pm on Jul 18, 2005 (gmt 0)

10+ Year Member



do you have "RewriteEngine On" at the top?

ChadSEO

10:39 pm on Jul 18, 2005 (gmt 0)

10+ Year Member



If it is from within your httpd.conf file, then the / at the beginning is valid, so you would want:

RewriteCond %{REMOTE_ADDR} ^161\.127\.48\.105$
RewriteRule ^/cc2k_login\$\.startup$ /cust_credit_app\$\.startup$1 [PT,L]

umakanth

1:01 pm on Jul 19, 2005 (gmt 0)

10+ Year Member



Yes I do have Rewrite ON.. following is how I have it in httpd.conf file

RewriteEngine ON
RewriteLog D:\OraHome1\Apache\Apache\logs\rewrite.txt
RewriteLogLevel 1
RewriteCond %{REMOTE_ADDR} ^161\.127\.48\.105$
RewriteRule /cc2k_login\$\.startup$ /cust_credit_app\$\.startup$1 [PT,L]

and it still does not work...

umakanth

1:43 pm on Jul 19, 2005 (gmt 0)

10+ Year Member



Thank you guys for all your help, I was able to make it work by adding folder information after the server name in the rewrite rule and it works now.

RewriteRule /myperl/cc2k_login\$\.startup$ /myperl/cust_credit_app\$\.startup$1 [PT,L]

Is there a way to know if the requested url is a redirect from another server.