LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-14-2009, 03:10 AM   #1
grezly
Member
 
Registered: May 2006
Distribution: Slackware
Posts: 46

Rep: Reputation: 15
[mod_rewrite] subdomain


I'm currently hosting my website on a external server (provider).
Now i'm trying to achieve the following:

I want to create for the user on my website a subdomain.

Not a 'real' subdomain, but only a nice and easy name.

For example: my website is example.com
A user has registerd on my website, his name is test.

The user can now visit his website on test.example.com.
When the user visits that site, it gets redirect to example.com/index.php/user/test.

A nice job for mod_rewrite, i think .

So i've created the next .htaccess in the root directory.

Code:
Options +FollowSymlinks
RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST} ([^.]+)\.example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/index.php/user/%1 [L,R=301]
But when i visit that website, it says that the website isn't found.

Did i make an error in the configuration file, or could it be an other problem i didn't think about of?
 
Old 04-14-2009, 03:31 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
RewriteRule ^(.*)$ http://www.example.com/index.php/user/%1
That "%1" at the end should be "$1" instead
 
Old 04-14-2009, 03:34 AM   #3
grezly
Member
 
Registered: May 2006
Distribution: Slackware
Posts: 46

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by bathory View Post
That "%1" at the end should be "$1" instead
Indeed, changed it but still the same error...
 
Old 04-14-2009, 03:53 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Take a look at error_log to see where is your request redirected.
Also check this example that is similar to what you want to achieve.
 
Old 04-15-2009, 01:26 AM   #5
grezly
Member
 
Registered: May 2006
Distribution: Slackware
Posts: 46

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by bathory View Post
Take a look at error_log to see where is your request redirected.
Also check this example that is similar to what you want to achieve.
When i view the access log i don't see anything (ofcourse), but when i visit the error log i see a message:

Code:
[Tue Apr 14 16:54:25 2009] [error] [client xxx.xxx.xxx.xxx] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /path/to/document_root/index.pl
At that time i did a request like: http://test.example.com.

Sounds familiar?
 
Old 04-15-2009, 02:08 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
It's not familiar, but anyway doing a little search, I think that it's better to move the "Options +FollowSymlinks" from .htaccess into the <Directory ...> part of the vhost test.domain.com.
Also make sure you have at least "AllowOverride Options" or "AllowOverride All" into the same <Directory ..> part.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Subdomain Redirection Using htaccess And mod_rewrite On Apache For Linux Or Uni LXer Syndicated Linux News 0 02-27-2009 09:00 AM
mod_rewrite: redirect depending on subdomain mysql_connect Linux - Server 1 08-01-2007 06:23 AM
Subdomain->IP? johndmann Linux - Networking 5 04-03-2006 04:09 AM
Subdomain help DoobyWho Linux - General 3 04-14-2003 06:51 PM
subdomain deepak Linux - Networking 2 03-01-2001 09:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration