开发者

Mod rewrite directory to subdomain (not the more common other way around)

When a user goes to example.com/page/-/filename.extension, I want them to see the file at m.example.com/page/-/filename.extension without a visible redirect. (I want all img src="http://example.com/page/-/..." references on my site to continue to work, t开发者_高级运维hough files are now hosted on m.example.com.)

I've tried dozens of permutations and but can't figure it out. What should this be?

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com/page/-/$ [NC]
RewriteRule ^page/-/(.*)$ http://m.example.com/page/-/$1 [L]
</IfModule>


It will not be possible without redirect using rewrite rules.

You can either make permanent redirect R=301 using rewrite rules.

Or if you want to avoid permanent redirect , you can use proxy_pass


This doesn't prevent a visible redirect, but I've tested and it does keep img tags intact:

RedirectMatch 301 ^/page/-/(.*)$ http://m.example.com/page/-/$1

Not sure if it needs any flags.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜