问个.htaccess通用写法怎么写

WBOY
Release: 2016-06-23 14:15:18
Original
1031 people have browsed it

RewriteCond %{HTTP_HOST} ^xxx.rtkuhn.com$ [NC]RewriteCond %{REQUEST_URI} !^/xxx/RewriteRule ^(.*)$ /xxx/$1RewriteCond %{HTTP_HOST} ^xxx.rtkuhn.com$RewriteRule ^(/)?$ /xxx/index.htm [L]
Copy after login

这段代码可以自动重写名字为xxx的子目录文件夹为二级域名,我想问下现在我有上百个这样的子目录,一个一个添加的话会很麻烦,通用的规则该怎么写呢?谢谢!


回复讨论(解决方案)

RewriteCond %{HTTP_HOST} ^([^\.]+).rtkuhn.com$ [NC]RewriteCond %{REQUEST_URI} !^/%1/RewriteRule ^(.*)$ /%1/$1RewriteCond %{HTTP_HOST} ^([^\.]+).rtkuhn.com$RewriteRule ^(/)?$ /%1/index.htm [L]
Copy after login
Copy after login

RewriteCond %{HTTP_HOST} ^([^\.]+).rtkuhn.com$ [NC]RewriteCond %{REQUEST_URI} !^/%1/RewriteRule ^(.*)$ /%1/$1RewriteCond %{HTTP_HOST} ^([^\.]+).rtkuhn.com$RewriteRule ^(/)?$ /%1/index.htm [L]
Copy after login
Copy after login

谢谢,虽然昨天我自己已经搞定了,但是还是要谢谢你!

进来支持一下。

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