0

I want like this Ex:

http://user1.mysite.com or http://user2.mysite.com if anyone enter URL Like these on browsers it should go as bellow

http://mysite.com/user.php?userName=user1

How can i solve this with .htaccess

With help of Prix i solved this Issue

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mysite\.com [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.mysite\.com
RewriteRule ^(.*)$ http://mysite.com/user.php?userName=%1 [R=301]

Its working fine :)

http://user1.mysite.com
http://mysite.com/user.php?userName=user1 -> This one is working fine with Prix Code

Now i want Like Bellow. I have tried lot but not working. So again i don't have anyway rather than ask here.

I want like this

http://user1.mysite.com/inbox/
http://mysite.com/inbox.php?userName=user1

FIXED

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mysite\.com [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.mysite\.com
RewriteRule ^inbox/$ http://mysite.com/inbox.php?userName=%1

And also Like this

http://user1.mysite.com/message/1
http://mysite.com/view-message.php?userName=user1&messageID=1

FIXED

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mysite\.com [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.mysite\.com
RewriteRule ^message/(.*)$ http://mysite.com/view-message.php?userName=%1&messageID=$1 [R=301]
4

1 回答 1

1

使用这样的条件应该做到这一点:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mysite\.com [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.mysite\.com
RewriteRule ^(.*)$ http://mysite.com/user.php?userName=%1 [R=301]

请记住,它将重定向所有子域。

于 2013-06-30T11:24:24.850 回答