2

I am devoloping a website with htaccess rules. This is the url structure:

example.com example.com/index.php/login example.com/index.php/foo demos.example.com 

For the last url above (demos.example) I would like to do show the content of example.com/index.php/demos, for this reason, I have create a .htaccess file as follow:

RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^(www\.)?demos.example.com RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php/demos [L] 

When I browse demos.example.com the index page is displayed (example.com), as nothing had happended. I hope that my explanation has been clear.

  • I have readed this topic, but this solution do a "browser redirection" and that is not the idea.
  • Using this example produces nothing: the index is displayed instead of index.php/demos

Update

If I use the .htaccess as follow:

RewriteCond %{HTTP_HOST} ^(www\.)?demos\.example\.com RewriteRule ^(.*)$ index.php/demos/$1 [L] 

...this make that the browser display a 500 internal server error. Viewing the log, it prints the following messages:

[Thu Dec 06 15:06:24 2012] [error] [client 201.192.30.254] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://example.com/ [Thu Dec 06 15:06:24 2012] [debug] core.c(3112): [client 201.192.30.254] r->uri = /index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/, referer: http://example.com/ [Thu Dec 06 15:06:24 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/, referer: http://example.com/ [Thu Dec 06 15:06:24 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/, referer: http://example.com/ [Thu Dec 06 15:06:24 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/, referer: http://example.com/ [Thu Dec 06 15:06:24 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/, referer: http://example.com/ [Thu Dec 06 15:06:24 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/, referer: http://example.com/ [Thu Dec 06 15:06:24 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/demos/index.php/demos/index.php/demos/index.php/demos/, referer: http://example.com/ [Thu Dec 06 15:06:24 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/demos/index.php/demos/index.php/demos/, referer: http://example.com/ [Thu Dec 06 15:06:24 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/demos/index.php/demos/, referer: http://example.com/ [Thu Dec 06 15:06:24 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/demos/, referer: http://example.com/ [Thu Dec 06 15:06:24 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /, referer: http://example.com/ 

1 Answer 1

1

Try this:

RewriteCond %{HTTP_HOST} ^(www\.)?demos\.example\.com [NC] RewriteRule ^(.*)$ http://example.com/index.php/demos/$1 [L] 
Sign up to request clarification or add additional context in comments.

5 Comments

This make a browser redirection instead for "point", as I mencioned in the post
Ah, so you want it to keep the URL intact, but show contents from another domain? I don't think it's possible actually.. Is it? I mean, I'm sure you should be able to do this via setting up a virtual server in your DNS records. But with .htaccess.. I doubt.
I think that it is posible. It is not from another domain, is just another "segment" from same domain.
Right, a subdomain. Okay, I'll be curious to see a solution myself then.
Well, It is not possible show content from another domain, but It is possible from the same domian (using the file name instead of full url). However, to make it works I has been a little hack but in the application side, nothing more to do with the .htaccess

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.