Forum Moderators: phranque

Message Too Old, No Replies

The Rewrite Rule: .Htaccess

Please Help Me

         

lovechina

7:49 am on Jan 11, 2007 (gmt 0)

10+ Year Member



Now I want to do this:

http://avi.example.com -> http://www.example.com/avi_index.html

http://avi.example.com/download.html ->http://www.example.com/avi_download.html

Below Is What I have Written in .htaccess:

RewriteEngine on
RewriteRule ^\.htaccess$ - [F]
rewritecond %{HTTP_HOST}!^www\.
rewritecond %{HTTP_HOST} ^([^.]+)\.example\.com
rewritecond $1!^a_
RewriteRule (.*) /%1_$1 [L]

But It Can't Work!

Wait Your Reply!

[edited by: jdMorgan at 8:23 am (utc) on Jan. 11, 2007]
[edit reason] example.com [/edit]

jdMorgan

8:21 am on Jan 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here is a better way to do that:

RewriteEngine on
#
RewriteRule \.htaccess$ - [F]
#
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{ENV:SdRw} !^done$
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
RewriteRule (.*) /%1_$1 [E=SdRw:done,L]

We set an environment variable named "SdRw" to "done" to prevent an infinite rewrite loop.

Jim

lovechina

8:31 am on Jan 11, 2007 (gmt 0)

10+ Year Member



The Rule should do this:

[avi.domain.com...] but not [avi.domain.com...]

the real url is :http://www.domain.com/avi_index.html, in the folder there's no "index.html"

and :
[avi.domain.com...]

the real url is:http://avi.domain.com/download.html

The Rule That You Write Can?