我的网站中有以下结构,我需要将所有流量重定向到子域
结构:
domain.com/subdomain/
.../folder1/folder/1.txt
.../folder1/folder/2.txt
.../folder2/folder/1.txt
.../folder2/folder/1.txt
.../index.php
我想将除 index.php 或 (domain.com/subdomain/) 之外的所有流量重定向到子域
例子:
domain.com/subdomain/folder1/folder/1.txt ---> subdomain.domain.com/folder1/folder/1.txt
domain.com/subdomain/folder1/folder/2.txt ---> subdomain.domain.com/folder1/folder/1.txt
但
domain.com/subdomain/index.php ---> No redirect
domain.com/subdomain/ ---> No redirect
这就是我想出的:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)$ http://subdomain.domain.com/$1 [NC]
这适用于所有请求,但我想从这个 RewriteRule 中排除 / & index.php
谢谢!