Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 通过虚拟子域重定向请求\u URI_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess 通过虚拟子域重定向请求\u URI

.htaccess 通过虚拟子域重定向请求\u URI,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我已经在一个网站上工作了一段时间了,当涉及到url重定向时,我被卡住了。我成功地为漂亮的配置文件页面创建了虚拟子域,但剩余参数有问题 我想做的是,当有人在地址行中键入username.mysite.net/about时,他/她应该被重定向到profile.php?u=username&t=about。目前,尝试访问username.mysite.net的用户将成功重定向到profile.php?u=username。但是当我尝试传递请求URI时,比如username.mysite.net/abo

我已经在一个网站上工作了一段时间了,当涉及到url重定向时,我被卡住了。我成功地为漂亮的配置文件页面创建了虚拟子域,但剩余参数有问题

我想做的是,当有人在地址行中键入username.mysite.net/about时,他/她应该被重定向到profile.php?u=username&t=about。目前,尝试访问username.mysite.net的用户将成功重定向到profile.php?u=username。但是当我尝试传递请求URI时,比如username.mysite.net/about,它会给出一个404错误

下面我复制了htaccess文件的相关部分

RewriteCond %{HTTP_HOST} !^www.mysite.net
RewriteCond %{HTTP_HOST} ^([^.]+).mysite.net
RewriteRule ^$ /profile.php?u=%1%{REQUEST_URI} [L]

我真的很感谢你的帮助。已经谢谢你了……

稍微调整一下就可以了:

RewriteCond %{HTTP_HOST} !^www.mysite.net
RewriteCond %{HTTP_HOST} ^([^.]+).mysite.net
RewriteRule ^(.*)$ /profile.php?u=%1&t=$1 [L]