Home > Backend Development > PHP Tutorial > 怎么编写二级域名跳转二级目录的伪静态或者php

怎么编写二级域名跳转二级目录的伪静态或者php

WBOY
Release: 2016-06-13 12:15:29
Original
1278 people have browsed it

如何编写二级域名跳转二级目录的伪静态或者php
目前目的达到的代码

RewriteEngine On<br /><br />RewriteCond %{HTTP_HOST} ^sell-meihualu.abc.com$ [NC]<br />RewriteRule (.*) http://www\.abc\.com/sell/meihualu/$1 [R=301,NC,L]
Copy after login



如何把sell设置为变量A
meihualu设置为变量B
实现
A-B.abc.com
跳转到对应的
www.abc.com/A/B/


或者有没大神可以PHP文件解决
本人刚学没多久

------解决思路----------------------
你那是 301 跳转,不是伪静态
跳转后 url 就变了

这是我用的
RewriteCond %{HTTP_HOST} ^([^\.]+).tool.net$
RewriteRule ^(/?)(.*)$ /users/%1/$2 [PT,L]
令形如 blog.tool.net/index.php 的 url 定位到 users/blog/index.php
url 不变

同理,你的规则写作这样就可以了
RewriteCond %{HTTP_HOST} ^([a-z]+)-([a-z]+).abc.com$ [NC]
RewriteRule (.*) http://www\.abc\.com/%1/%2/$1 [R=301,NC,L]

不会只有 sell-meihualu.abc.com 这样一个二级域名吧?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template