Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
Php 如何使用htaccess将我的用户配置文件URL转换为子域_Php_.htaccess_Mod Rewrite_Nginx - Fatal编程技术网

Php 如何使用htaccess将我的用户配置文件URL转换为子域

Php 如何使用htaccess将我的用户配置文件URL转换为子域,php,.htaccess,mod-rewrite,nginx,Php,.htaccess,Mod Rewrite,Nginx,如何将我的用户配置文件URL转换为子域 具有htaccess 我尝试在htaccess中使用此代码,但不起作用 Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^(iemg\.net)$ [NC] RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L] 比如:首先,您必须捕获

如何将我的用户配置文件URL转换为子域 具有htaccess

我尝试在htaccess中使用此代码,但不起作用

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(iemg\.net)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

比如:首先,您必须捕获域的用户部分,然后在替换中使用它

RewriteCond %{HTTP_HOST} ^(.*)\.iemg\.net$ [NC]
RewriteRule ^ http://iemg.net/usersprofile.php?username=%1 [R,L]

当一切正常工作时,您可以将
R
替换为
R=301
。切勿使用进行测试。

请包括原始URL和您希望重写的URL。这使调试更容易。代码已更新。我已将您的代码添加到我的htaccess文件中,当我输入此路径时发现此错误
“无法访问此站点用户名11。找不到iemg.net的服务器DNS地址。”
这与重写规则无关。当然,您必须先设置DNS地址,然后才能工作。您还需要设置Apache的虚拟主机配置来为这些域提供服务。通配符DNS条目也应该起作用。