[英]How to redirect Sub domain as attribute in page with .htaccess
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://user1.mysite.com
或http://user2.mysite.com
如果有人在浏览器中输入网址),则应像下面这样
http://mysite.com/user.php?userName=user1
How can i solve this with .htaccess 我如何用.htaccess解决此问题
With help of Prix i solved this Issue 在Prix的帮助下,我解决了这个问题
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]
Using condition like this should do it: 使用这样的条件应该做到这一点:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mysite\.com [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.mysite\.com
RewriteRule ^(.*)$ http://mysite.com/user.php?userName=%1 [R=301]
Keep in mind it will redirect all the sub-domains. 请记住,它将重定向所有子域。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.