我正在尝试使用.htacess创建自定义域名。
以下是我正在做的事情
http://username.mydomain.com正在访问http://mydomain.com/live/agent/index.php?agent_user_name=username (工作正常)
这是.htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com$ [NC]
RewriteCond %1 !^www$ [NC]
RewriteRule ^$ /live/agent/index.php?agent_user_name=%1 [L]但是现在我也想处理其他的页面
http://username.mydomain.com/blog应该访问http://mydomain.com/live/agent/blog.php?agent_user_name=username
请帮助如何在.htaccess中处理这一问题
发布于 2014-03-28 14:09:51
您可以使用以下附加规则:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com$ [NC]
RewriteRule ^/?$ /live/agent/index.php?agent_user_name=%1 [L]
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com$ [NC]
RewriteRule ^(.+?)/?$ /live/agent/$1.php?agent_user_name=%1 [L]https://stackoverflow.com/questions/22713415
复制相似问题