我的移动应用程序有一个子域,就像http://m.traffic.domain.com http://m.traffic.domain.com现在我希望我的用户可以通过访问访问他们的页面http://m.traffic.domain.com/用户名 http://m.traffic.domain.com/username这将在内部指向http://m.traffic.domain.com/index.php?用户名= http://m.traffic.domain.com/index.php?username=1 美元
为此,我有以下 .htaccess 重写代码,但它没有按预期工作,而是将所有页面重定向到http://m.traffic.domain.com/index.php?用户名= http://m.traffic.domain.com/index.php?username=1 美元这个
页
# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php
AddHandler application/x-httpd-php .aspx
RewriteEngine On
RewriteCond %{HTTP_HOST} ^m\.traffic\.domain\.com$ [NC]
RewriteCond %1 !^www$ [NC]
RewriteRule ^(.+)$ mobile/index.php?username=%1 [L]
<Files 403.shtml>
order allow,deny
allow from all
</Files>
子域http://m.traffic.domain.com http://m.traffic.domain.com指向一个名为 mobile 的目录,可以访问该目录http://traffic.domain.com/mobile http://traffic.domain.com/mobile
试试这个代码:
# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php
AddHandler application/x-httpd-php .aspx
RewriteEngine On
RewriteCond %{HTTP_HOST} ^m\.traffic\.domain\.com$ [NC]
RewriteRule ^([^.]+)/?$ /index.php?username=$1 [L,QSA]
<Files 403.shtml>
order allow,deny
allow from all
</Files>
匹配的组来自RewriteRule
are $1, $2
代替%1, %2
你不需要/mobile
因为你的要求是为了m.traffic.domain.com
not traffic.domain.com
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)