Forum Moderators: phranque

Message Too Old, No Replies

rewrite but not 1 page

         

jackvull

5:55 pm on Oct 17, 2010 (gmt 0)

10+ Year Member



My host company only allows cronjobs to be run by creating a php page and having the webserver run it.
Unfortunately, they run the cronjob by directing the page to [mysite.com...]

I have a redirect for google on my site with:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite.co.uk$
RewriteRule (.*) [mysite.co.uk...] [R=301,L]

How can I tell the redirect to ignore the one cronjob script?

jdMorgan

7:13 pm on Oct 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Add

RewriteCond $1 !^URL-path-to-cronjob-script\.script-filetype$

Literal spaces in regular-expressions patterns (such as your hostname) should be escaped as shown for the filetype here. Further, you should not end-nachor the hostname, and might consider using the [NC] flag on that RewriteCond. Your rule will do nothing if the non-canonical hostnames www.mysite.co.uk., www.mysite.co.uk:80, or www.mysite.co.uk.:80 are requested. If you do not use additional subdomains on this site, consider using:

RewriteEngine on
#
RewriteCond %{HTTP_HOST} !^(www\.mysite\.co\.uk)?$
RewriteCond $1 !^URL-path-to-cronjob-script\.script-filetype$
RewriteRule ^(.*)$ http://www.mysite.co.uk/$1 [R=301,L]

instead, to allow only a blank hostname or an exact match to bypass redirection.

See Apache mod_rewrite documentation for more info.

Jim

jackvull

7:55 pm on Oct 17, 2010 (gmt 0)

10+ Year Member



Hmm
It is still forwading the script page to www with that change?

RewriteEngine On
#
RewriteCond %{HTTP_HOST} !^(www\.mysite\.co\.uk)?$
RewriteCond $1 !^http://mysite.co.uk/cart/updateorders.php\.script-filetype$
RewriteRule ^(.*)$ [mysite.co.uk...] [R=301,L]

jdMorgan

8:23 pm on Oct 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"URL-path" has a specific meaning. It means the "local" path, and "script-filetype" was meta-language, because you did not specify your script's URL-path in your initial post:

RewriteEngine On
#
RewriteCond %{HTTP_HOST} !^(www\.mysite\.co\.uk)?$
RewriteCond $1 !^cart/updateorders\.php$
RewriteRule ^(.*)$ ttp://www.mysite.co.uk/$1 [R=301,L]

Jim