doushi7314 2015-12-21 19:14
浏览 45

配置htaccess目录索引文件

Scenario: I created this htacces file to redirect subdomains. So far it works.

<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.example\.net$ [NC]
RewriteRule ^(.*) http://example.net/%1/$1 [P,NC,QSA]
</IfModule>

Problem:

It forces the server to request an arbitrary index.php which doesn't exist. What I do have is index.html, so I'm getting:

Error 404: /xyz/index.php was not found on this server

I tried adding:

DirectoryIndex index.html index.php [L]

But only 1st argument gets accepted, the 2nd gets ignored (why?). AFAIK it should accept either of those as long as either exist.

  • 写回答

1条回答 默认 最新

  • dousi7919 2015-12-21 19:24
    关注

    try this: i copy this and work right.

    <IfModule mod_rewrite.c>
    
        RewriteEngine on
    
        RewriteRule    ^$    public/    [L]
    
        RewriteRule    (.*) public/$1    [L]
    
    </IfModule>
    

    you should change 'public' to your folder.

    评论

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办