开发者

Htaccess rules to rewrite pages inside folder to the root?

The is my real folder scheme:

ROOT
index.html
news.html
+articles
|-obama.html
|-oil.html

I want some htaccess rule so if people go to domain.com/ob开发者_如何学Cama.html the server will fetch the one in the articles folder without redirecting.

If some one goes to domain.com/index.html will still fetchs the one in the articles even if there is an index in the ROOT.

Thanks


Try this:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond articles/%{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ articles/$1 [QSA]


RewriteRule .* articles/$1 [L,QSA]


Why don't you just use:

# RewriteRule /obama.html$ /articles/obama.html [L]
RewriteCond %{REQUEST_URI} !^/{index,news}.html$
RewriteRule (.*)$ /articles/$1 [L]

?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜