的.htaccess URL重写的子域 [英] .htaccess url rewrite for sub-domain

查看:178
本文介绍了的.htaccess URL重写的子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在子域中的页面 domain.com/blog/landing-page /

我想打开它作为 domain.com / 这样用户就不会知道我的网页的位置。

I want to open it as domain.com/ so user will not know where my page is located.

我尝试以下code,但它并没有为我工作,

I try below code but it doesn't work for me,

RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+blog/landing-page[/\s] [NC]
RewriteRule ^ / [R=301,L]

我写了这一点,但它开域/博客

I wrote this but it open domain/blog

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+blog/landing-page/([^\s]+) [NC]
RewriteRule ^ %1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (?!^dirname/)^(.*)$ /blog/landing-page/$1 [L,NC]

我怎样才能使它发挥作用?

How can i make it work ?

推荐答案

这应该在根目录的.htaccess:

This should work in root .htaccess:

RewriteEngine On

RewriteCond %{THE_REQUEST} \s/+blog/landing-page[/\s?] [NC]
RewriteRule ^ /? [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?!blog/landing-page/).*)$ /blog/landing-page/$1 [L,NC]

这篇关于的.htaccess URL重写的子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆