开发者

Htaccess rules to rewrite pages inside folder to the root?

开发者 https://www.devze.com 2023-01-26 18:42 出处:网络
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

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

精彩评论

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

关注公众号