Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.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
Mod rewrite 重写像bigcommerce.com这样的子域url_Mod Rewrite_Subdomain - Fatal编程技术网

Mod rewrite 重写像bigcommerce.com这样的子域url

Mod rewrite 重写像bigcommerce.com这样的子域url,mod-rewrite,subdomain,Mod Rewrite,Subdomain,我有两个文件夹a和b 我想像子域样式一样重写url domain.com/a=>a.domain.com=>它将运行文件夹a domain.com/b=>b.domain.com=>它将运行文件夹b 提前感谢假设文件夹a和b位于域的根目录,尝试将其添加到web文档根文件夹中的.htaccess文件(通常是public\u html或htdocs): 这假设mod_rewrite已安装且已为.htaccess文件激活。 如果不确定是否安装了mod_rewrite,请查看phpinfo()输出中已安

我有两个文件夹ab

我想像子域样式一样重写url

domain.com/a=>a.domain.com=>它将运行文件夹a

domain.com/b=>b.domain.com=>它将运行文件夹b


提前感谢

假设文件夹
a
b
位于域的根目录,尝试将其添加到web文档根文件夹中的
.htaccess
文件(通常是
public\u html
htdocs
):

这假设mod_rewrite已安装且已为
.htaccess
文件激活。 如果不确定是否安装了mod_rewrite,请查看
phpinfo()输出中已安装模块的列表
默认情况下,
.htaccess
文件未启用mod_rewrite。如果您正在管理自己的服务器,请打开
httpd.conf

并确保webroot目录块包含以下行之一:
AllowOverride FileInfo
AllowOverride All

谢谢您的评论,但它不起作用,它会导致500个内部服务器错误您确定安装了mod rewrite吗?(请参阅答案中的说明。)我确定,我发现了您的错误,在最后一行中,^和%之间有一个空格。我把它拿走了。它运行了,但不正确,当我键入a.domain.com时,它没有运行到文件夹a或b中。它在根目录下运行index.php
在^和%
之间有一个空格,该空格是正确的。它导致500个内部服务器错误。我不知道为什么
Options -Multiviews
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([ab])\.domain\.com [NC]
RewriteRule ^ %1%{REQUEST_URI} [L]