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
.htaccess URL重写子域_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess URL重写子域

.htaccess URL重写子域,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我会很快知道我要做什么 基本上,我有一个用户配置文件页面,可以作为我的url,比方说 profile.php?user=alex 所以现在在我的.htaccess文件中运行良好的是将其更改为 website.com/alex 以便更快地访问 另一方面,我需要基本上 alex.website.com 但是我想不出一种方法来重写我的URL,而不是为每个用户都提供一个子域 如果你有任何想法,如果这是可能的&我将如何继续这样做,我将不胜感激 多谢各位 Alex要重写URL路径,请尝试以下规则:

我会很快知道我要做什么

基本上,我有一个用户配置文件页面,可以作为我的url,比方说

profile.php?user=alex
所以现在在我的.htaccess文件中运行良好的是将其更改为

 website.com/alex
以便更快地访问

另一方面,我需要基本上

 alex.website.com
但是我想不出一种方法来重写我的URL,而不是为每个用户都提供一个子域

如果你有任何想法,如果这是可能的&我将如何继续这样做,我将不胜感激

多谢各位


Alex要重写URL路径,请尝试以下规则:

RewriteRule ^[a-z]+$ profile.php?user=$0
RewriteCond %{HTTP_HOST} ^([a-z]+)\.example\.com$
RewriteRule ^$ profile.php?user=%1
如果您的用户名有不同的语法,请根据需要替换
[a-z]

要重写主机,请尝试以下规则:

RewriteRule ^[a-z]+$ profile.php?user=$0
RewriteCond %{HTTP_HOST} ^([a-z]+)\.example\.com$
RewriteRule ^$ profile.php?user=%1

注意,这只会在内部将
//alex.example.com/
重写为
//alex.example.com/profile.php?user=alex
。此外,您的服务器已经需要配置为接受域的任何子域(请参阅和)。

若要仅重写URL路径,请尝试以下规则:

RewriteRule ^[a-z]+$ profile.php?user=$0
RewriteCond %{HTTP_HOST} ^([a-z]+)\.example\.com$
RewriteRule ^$ profile.php?user=%1
如果您的用户名有不同的语法,请根据需要替换
[a-z]

要重写主机,请尝试以下规则:

RewriteRule ^[a-z]+$ profile.php?user=$0
RewriteCond %{HTTP_HOST} ^([a-z]+)\.example\.com$
RewriteRule ^$ profile.php?user=%1
注意,这只会在内部将
//alex.example.com/
重写为
//alex.example.com/profile.php?user=alex
。此外,您的服务器已经需要配置为接受域的任何子域(请参阅和)