Forum Moderators: phranque

Message Too Old, No Replies

Curious .htaccess problem

htaccess rewritecond problem

         

attilat1

2:32 pm on Jun 30, 2009 (gmt 0)

10+ Year Member



Hello,

This is my first post, after reading a lot of threads i decided to ask my own question. Maybe I'll get an answer that will work.

Here is the thing:
I have some .cc and .it domains which I would like to host them on my hosting account so I set an A record to point them to my hosting IP.

There I added this lines to the .htaccess:

RewriteCond %{HTTP_HOST} ^site\.it$ [OR]
RewriteCond %{HTTP_HOST} ^www\.site\.it$
RewriteCond %{REQUEST_URI} !^/local_directory_path/
RewriteRule (.*) /local_directory_path/$1

I get an 404 error: "The requested URL /local_directory_path/site.it/ was not found on this server."

It works for all .cc but it doesn't work for the .it domains, may I ask why?

jdMorgan

10:36 pm on Jun 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Likely a problem caused by interaction with another rule; I note that you did not use the [L] flag on this rule, and if you didn't use it on your other rules, then all rules will execute in sequence, perhaps causing unintended results.

Either that, or there is some difference in how you configured this "add-on domain."

The question here is "How did 'site.it/' get appended to the URL-path?"

Side note: Your first two RewriteConds above reduce to


RewriteCond %{HTTP_HOST} ^(www\.)?site\.it

and the hostname should not be end-anchored unless you have previously passed a canonical-hostname test to be sure it's not an FQDN and does not have a port number appended (e.g. www.site.it.:80 is quite valid, but will break your rule.)

Jim

attilat1

12:53 pm on Jul 1, 2009 (gmt 0)

10+ Year Member



I removed all other rules and still the same error. I don't know what to do next.

jdMorgan

2:45 pm on Jul 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Find out how the server "knows" about the "site.it" subdirectory path. That information is being injected into the URL-path at some point, and you will need to find out where that is happening in order to come up with a fix or a work-around.

It could be:

  • Code in a server config file, inserted by the "add domain" function of your control panel.
  • Content-negotiation/MultiViews configuration at the config or .htaccess files.
  • Rewrites in other .htaccess files in the directory-path to the requested resource.
  • etc.

    Jim

  •