problem of directory

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 1
Joined: 16 Apr 2012, 05:33

problem of directory

16 Apr 2012, 07:09

my current url
http://www.mysite.com/hospital/index.aspx?hospital=name

I need it well to
http://hospital.mysite.com/hospital/name/

this is my code:
in the root directory——.htaccess
Code: Select all
RewriteCond %{HTTP_HOST} ^hospital\.mysite\.com [NC]
RewriteRule (.*)$ /hospital/$1 [NC]


in the directory of hospital—— .htaccess
Code: Select all
RewriteRule ^([^/]*)/$ Index.aspx?hospital=$1 [NC]


if url is "http://hospital.mysite.com/hospital1/" ,can get query string value hospital=hospital1,
but when the url like "http://hospital.mysite.com/hospital/",can't get query string value "hospital"

Any help appreciated.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: problem of directory

17 Apr 2012, 07:18

Hello,

I'd suggest the following set of rules located in the same .htaccess in the root of your site:

Code: Select all
RewriteCond %{HTTP_HOST} ^www\.mysite\.com [NC]
RewriteCond %{QUERY_STRING} ^([^=&]+)=([^&]+)$
RewriteRule ([^/]+)/index\.aspx$ http://%1.mysite.com/%1/%2 [NC]


RewriteCond %{HTTP_HOST} !^www\.mysite\.com [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.mysite\.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([^/]+)/([^/]+) http://www.mysite.com/$1/index.aspx?$1=$2 [NC,P]


This may also give you a basic idea, if not the complete solution.

Regards
Andrew

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 16 guests