1

我需要修改文件请求 http://subdomain.site.com/file.txt -> http://site.com/file-subdomain.txt 请帮助处理 htaccess 代码。谢谢!

4

1 回答 1

2

通过启用 mod_rewrite 和 .htaccess httpd.conf,然后将此代码放在您.htaccessDOCUMENT_ROOT目录下:

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

RewriteCond %{HTTP_HOST} ^(subdomain)\.(site\.com)$ [NC]
RewriteRule ^file\.txt$ http://%2/file-%1.txt [L,R=301,NC]

编辑:

RewriteCond %{HTTP_HOST} ^(subdomain)\.(site\.com)$ [NC]
RewriteRule ^file\.txt$ /file-%1.txt [L,NC]
于 2013-09-12T21:11:05.367 回答