Forum Moderators: phranque

Message Too Old, No Replies

Converting config in httpd.conf to .htaccess

migrating site from dedicated to shared hosting

         

pinkpjs

7:29 pm on Jun 15, 2009 (gmt 0)

10+ Year Member



I am no Apache expert.
I am trying to move a web site from a dedicated server onto a shared hosting environment.
I have the httpd.conf file with lots of config settings in it and have tried pasting them into the .htaccess file under a VirtualHost.
I am getting an inetrnal server error but no idea why.
The config settings are simply a bunch of RewriteRule statements and a couple of AddType statements, some SetEnvIf statements and php_value statements plus a <Location "/">
Options +Indexes +MultiViews
ErrorDocument 404 /error404.html
order allow,deny
allow from all
</Location>
Ok i guess that a lot of config. Trouble is I didn't write the application & have no idea what the conifg is supposed to do.
Any suggestions greatly appreciated. My hosting company is being typically unhelpful!

jdMorgan

1:18 am on Jun 16, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Remove the <Location> container completely (both the <Location> and its closing </Location> directive), and disable MultiViews unless you require them.

Jim

g1smd

8:54 pm on Jun 16, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Make sure that Mod_Rewrite and any other modules that you'll be needing have been activated in the http.conf of that server.

I recently ran in to an issue where both Mod_MIME and Mod_Expires weren't loaded.

jkovar

11:54 pm on Jun 16, 2009 (gmt 0)

10+ Year Member



Determine the Apache version running on the new server.

Go to this index of Apache directives, replacing "2.2" with your Apache version in the URL.
[httpd.apache.org...]

Lookup each directive that you want to carry over from the conf, for instance here is the entry for AddType.
[httpd.apache.org...]

You will see details about the directive, one line will be the "context" that directive is available in.
For instance with the AddType directive, it looks like this,

Context: server config, virtual host, directory, .htaccess

If ".htaccess" is not listed for that directives "context", you can not use it in htaccess. Having it in the htaccess file will either be ignored or cause that 500 Internal Server error depending on your setup.

That <Location> container is an example of a directive that is not available in htaccess context. Considering the meaning of that directive, it may or may not be as simple as placing the directives enclosed in that container within a certain folders htaccess file.

Once you've got your contexts squared away, since you're going into the "end of the line" which is htaccess, you'll want to pay attention to the "override" line that's right there near the "context" line.

This is where it can get annoying with shared hosting, as far as I know the only way to determine the level of overrides you have, is to look in the server configuration files for the AllowOverride directive.
[httpd.apache.org...]

On a strict setup, you may be able to use certain directives context-wise, but the AllowOverride directive could be preventing you from using it permission-wise.

pinkpjs

6:18 pm on Jun 17, 2009 (gmt 0)

10+ Year Member



Thanks for all the replies. The hosting company got back to me today saying that VirtualHost and DocumentRoot are pre-defined by them. I was trying to set these up in my .htaccess so thats what's been causing the 500 error. My application is serving out of a different directory than their pre-defined (/web) one so now I am faced with having to move the entire site from /web/docs/* into /web/*
It's very frustrating and makes me want to find a different web host - one that offers dedicated hosting. I'd be interested to know what you all think..?

g1smd

11:07 pm on Jun 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



URLs are not the same thing as internal server filepaths, so you can use / in the URLs and use a rewrite so that the content is served from the /web/docs/ folder on the server, without revealing that is what is happening. This is a common question in this forum.

pinkpjs

3:26 am on Jun 18, 2009 (gmt 0)

10+ Year Member



Thanks. Could you give me an example of what such a rewrite would look like?

jdMorgan

12:40 pm on Jun 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A thorough review of the mod_rewrite documentation at apache.org would be a very good idea.

RewriteRule ^URL-path-pattern$ /server-local-filepath [L]

Jim