Forum Moderators: phranque

Message Too Old, No Replies

Subdomains and .htaccess

Options +FollowSymLinks -MultiViews

         

el_roboto

6:44 pm on May 16, 2007 (gmt 0)

10+ Year Member



I'm thinking of introducing an e-newsletter administration section to the website which I'm planning on creating a subdomain for

[mailmanager.companyname.com...]

I'd like this domain to read from

[companyname.com...]

So I'm wondering how I would amend the htaccess file to give this instruction.


Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteRule ^(.*)/$ index.php?id=$1 [NC]
RewriteCond %{REQUEST_URI}!(\.[^/]*¦/)$
RewriteRule (.*) [companyname.com...] [R=301]
ErrorDocument 404 /index.php?id=404 [NC]

jdMorgan

1:11 am on May 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See this previous thread to get started: [webmasterworld.com...]

For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim

[edited by: jdMorgan at 8:05 pm (utc) on May 25, 2007]

el_roboto

4:59 pm on May 19, 2007 (gmt 0)

10+ Year Member



thanks for the link

been playing around wit this for some time now, latest effort was

Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteRule ^(.*)/$ index.php?id=$1 [NC]
RewriteCond %{REQUEST_URI} !(\.[^/]*¦/)$
RewriteRule (.*) http://www.example.com/$1/ [R=301]
ErrorDocument 404 /index.php?id=404 [NC]
RewriteCond %{HTTP_HOST} ^enews.example.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.enews.example.com$
RewriteRule ^(.*)$ http://www.example.com/enews/ [R,L]

if I request enews.example.com I encounter a "server cannot be found....."

and now also when I'm requesting www.example.com/home/ I'm getting internal server error

any suggestions on alternatives?

[edited by: jdMorgan at 6:31 pm (utc) on May 19, 2007]
[edit reason] Example.com [/edit]

jdMorgan

6:30 pm on May 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> if I request enews.website.com I encounter a "server cannot be found....."

You need to configure an A record in your DNS zone file to point wildcard subdomains to your server's IP address.

If you do not have a unique IP address for your site, you will also need to define the new hostnames (subdomains) in the server configuration. You may be able to do this with a control panel, or your host may do it for you. Or they may refuse.

> and now also when I'm requesting www.example.com/home/ I'm getting internal server error

Check your server error log for more information.

Also, are you sure you want an external redirect in your last rule? It will show the /enews subdirectory in the visitor's address bar, and this URL will also be indexed in the search engines. Most of the time for cases like this, an internal rewrite is used instead.

Jim

[edited by: jdMorgan at 6:33 pm (utc) on May 19, 2007]

el_roboto

10:20 am on May 24, 2007 (gmt 0)

10+ Year Member



thanks jim :)