在第二个网站上显示第一个网站的内容

时间:2019-02-09 11:53:29

标签: .htaccess url url-rewriting

我建立了一个博客,其中包含多个类别,跨越多个细分市场,并希望将多个类别拆分/分组为多个url。

所以我有

class RecyclerSoundScreenAdapter(val context: Context, val song: List<Sound>) : RecyclerView.Adapter<RecyclerSoundScreenAdapter.Holder>() { private var mediaPlayer: MediaPlayer? = null private var currentPlayingSound: Sound? = null override fun onBindViewHolder(holder: Holder, position: Int) { holder.bind(song[position]) } override fun getItemCount(): Int { return song.count() } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder { val view = LayoutInflater.from(context).inflate(R.layout.sound_template, parent, false) return Holder(view) } fun releaseMediaPlayer() { mediaPlayer?.release() mediaPlayer = null } inner class Holder(itemView: View) : RecyclerView.ViewHolder(itemView) { fun bind(sound: Sound) = with(itemView) { songTitle.text = sound.title testButtonPlay.setOnClickListener { if (currentPlayingSound == sound) { if (mediaPlayer?.isPlaying == true) { mediaPlayer?.pause() } else { mediaPlayer?.start() } } else { if (mediaPlayer?.isPlaying == true) { mediaPlayer?.release() mediaPlayer = null } currentPlayingSound = sound mediaPlayer = MediaPlayer.create(context, sound.resId) mediaPlayer?.start() } } } } } ,它将重写为website-one.com/blog/category.php?name=$1&page=$2

所以假设我有:

website-one.com/blog/music/1website-one.com/blog/music/1website-one.com/blog/fashion/1

我希望能够使用同一网站,但要在完全独立的域上镜像内容:

website-one.com/blog/sport/1

因此,我并不是要在一个站点上完全复制一个站点,而是要选择一个要显示在每个域上的类别,并使用一个站点作为主要管理站点。

是否可以通过简单的重写规则或服务器端脚本来实现?

我担心的是分页,这意味着当人们单击website-two.com/blog/cooking/1按钮时,他们不会从域2重定向回域1(从Next Page重定向到website-two.com/blog/cooking/1)。

1 个答案:

答案 0 :(得分:0)

在website-one.com上的.htaccess中,添加Cooking / 1重写到第二个域

RewriteRule ^blog\/cooking\/1$ http://website-two.com/blog/cooking/1 [R=301,L]

在website-two.com上的.htaccess中,添加Cooking / 2重写回第一个域

RewriteRule ^blog\/cooking\/2$ http://website-one.com/blog/cooking/2 [R=301,L]