我想将我的网站上的子文件夹指向子域。例如,我想将www.domain.com/test改为test.domain.com。我之前在网站构建过程中已经使用过htaccess中的一些重写功能,我希望能够在不干扰这些的情况下添加此行。在htaccess中使用子目录作为子域
我已经尝试了几十个对这个问题的答案,我在网上找到了这些问题,但是他们中的任何一个似乎都无法正常工作,而且我也不确定是否由于缺乏这门语言的知识或者与之有冲突别的东西。
我尝试最新的线路有:
RewriteCond %{HTTP_HOST} !^www.domain.tv
RewriteCond %{HTTP_HOST} ([^.]+).domain.tv
RewriteRule ^(.*)$ /var/www/www.domain.tv/test%1
这是我目前htaccess文件:
Options +FollowSymLinks
RewriteEngine On
RewriteBase/
#RewriteCond %{HTTP_HOST} !www\.domain\.tv$ [NC]
#RewriteCond %{HTTP_HOST} ^(.+)\.domain\.tv$ [NC]
#RewriteRule .* index.php?option=com_contushdvideoshare&view=player&Itemid=33 [L]
RewriteCond %{REQUEST_URI} ^/album\/t\/([a-zA-Z0-9]+) [NC]
RewriteRule ^album/t/(.*) index.php?option=com_usermenu&task=directdownload&id=$1&type=one$
RewriteCond %{REQUEST_URI} ^/album\/([a-zA-Z0-9]+) [NC]
RewriteRule ^album/(.*) index.php?option=com_usermenu&task=directdownload&id=$1 [L]
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} (/[^.]*|\.(php|html?|feed|pdf|raw))$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
谁能帮助我在这里?
导致一个如下所示的URL:http://www.domain.tv/testest – user1429324
不知道你想要什么 - 我从规则中删除了测试。现在试试? – Ansari
我想指出www.domain.tv/test显示并运行test.domain.tv。我想我可能在htaccess文件中有其他行阻止其他子域名。我感谢您的帮助! – user1429324