开发者

simple redirect to default page with htaccess

The htaccess file requires an entry at the end of /folder/ to redirect the page

example:

http://www.server.com/开发者_JAVA技巧folder/"some-page-name"

If no page is defined as, then I want it to be "index" by default

the htacess

RewriteBase /folder/
RewriteRule ^(.*)$ subfolder/index.php/?page=$1 [L]


# there must be something after /folder/ for this to work
RewriteBase ^/folder/(.+)$  /folder/subfolder/index.php/?page=$1 [L]

# if there isn't, do a catch-all redirect (change to whatever "index by default" means)
RewriteRule ^/folder/$      /folder/index


If you want to check whether the file exists or not and redirect the users to the index (if is does not), use the following condition:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond .* index [R=301]
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜