문제

I am trying to create custom domain names using .htacess

Here is what i am doing

http://username.mydomain.com is accessing http://mydomain.com/live/agent/index.php?agent_user_name=username (working fine)

here is .htaccess

RewriteEngine on

RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com$ [NC]

RewriteCond %1 !^www$ [NC]

RewriteRule ^$ /live/agent/index.php?agent_user_name=%1 [L]

But now I want to handle other pages as well

http://username.mydomain.com/blog should access http://mydomain.com/live/agent/blog.php?agent_user_name=username

Please help how to handle this as well in .htaccess

도움이 되었습니까?

해결책

You can have this additional rule:

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]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top