Forum Moderators: phranque

Message Too Old, No Replies

rewriting .htaccess to httpd.conf

.htaccess needs to be converted to httpd.conf

         

kenchix1

12:26 pm on Jun 1, 2007 (gmt 0)

10+ Year Member



I have a websites that uses .htaccess to redirect a subdomain to a certain script. It was working properly until I moved to another host and they told me that I have to need a code inside the httpd.conf (wildcard or something like that) to make it work. Problem is I don't know anything about httpd.conf because I was able to build my .htaccess file using the samples here at webmasterworld.com along with the help of several members and mods.

this is how my .htaccess looks like, do I really need to convert this to httpd.conf code to make my redirection work again? the host said they are willing to inject the code in httpd.conf themselves if I can provide it.

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.sample3\.ccc
RewriteRule (.*) [%1.sample1.ccc...] [R=301,L]
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.sample2\.ccc
RewriteRule (.*) [%1.sample1.ccc...] [R=301,L]
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.sample1\.ccc
RewriteRule (.*) [%1.sample1.ccc...] [R=301,L]

#
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER}!^http://(www\.)?sample3\.ccc [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?sample2\.ccc [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?sample1\.ccc [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?sample4\.ccc [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?sample5\.ccc [NC]
RewriteRule \.(jpe?g¦gif¦png¦bmp)$ - [F,NC]

#
RewriteCond %{REQUEST_URI}!^/mypage\.php
RewriteCond %{HTTP_HOST}!^www\.sample1\.ccc
RewriteCond %{HTTP_HOST} ^([^.]+)\.sample1\.ccc
RewriteRule .* [sample1.ccc...] [R]

RewriteCond %{REQUEST_URI}!^/mypage\.php
RewriteCond %{HTTP_HOST}!^www\.sample3\.ccc
RewriteCond %{HTTP_HOST} ^([^.]+)\.sample3\.ccc
RewriteRule .* [sample1.ccc...] [R]

RewriteCond %{REQUEST_URI}!^/mypage\.php
RewriteCond %{HTTP_HOST}!^www\.sample2\.ccc
RewriteCond %{HTTP_HOST} ^([^.]+)\.sample2\.ccc
RewriteRule .* [sample1.com...] [R]

Thanks in advance.

jdMorgan

1:25 pm on Jun 1, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You don't need to convert anything, and you report your host as not saying that, either.

I suspect that what they said was that you need to edit httpd.conf to define wildcard subdomains. Otherwise, the server will not recognize any subdomains at all (except, in all likelihood, "www").

The relevant directive for use in httpd.conf is "ServerAlias," as described in the Apache core directives and Name-Based Virtual Server documentation. This can be used to tell the server that " *.example.com " is an alias for "example.com", as is "www.example.com".

The remaining question, which you may be able to answer from your host's previous reply, is whether you have permissions to edit httpd.conf. If not, ask them to do it -- It's an easy edit and no big deal IF you've done it before.

Jim

kenchix1

2:15 am on Jun 2, 2007 (gmt 0)

10+ Year Member



They said that they are willing to put the code for me inside the httpd.conf if I have it. I just can't understand why the .htaccess doesn't work now but it work in another host before without me touching anything inside the httpd.conf. Does it mean my .htaccess is useless now that I need to have the wildcard subdomain in httpd.conf? Sorry I really don't understand .httpd.conf very well. Thanks for your reply and patience.

jdMorgan

11:59 pm on Jun 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The relevant directive for use in httpd.conf is ServerAlias [httpd.apache.org], as described in the Apache core directives and Name-Based Virtual Server documentation. This can be used to tell the server that " *.example.com " is an alias for "example.com", as is "www.example.com".

If you define wildcard subdomains using the ServerAlias directive and restart your server, your code will most likely work again without any changes.

Jim