problem of directory
2 posts
• Page 1 of 1
problem of directory
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
in the directory of hospital—— .htaccess
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.
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.
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: problem of directory
Hello,
I'd suggest the following set of rules located in the same .htaccess in the root of your site:
This may also give you a basic idea, if not the complete solution.
Regards
Andrew
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
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 16 guests