我目前使用ipage作为主机并且有一个指向index.html的域。但是,我需要该域指向一个index.php来代替。所以我创建了一个.htaccess并且只写了; DirectoryIndex index.php index.html并保存它,但它不起作用,用户仍然被定向到index.html。有一个问题,index.php位于名为“SourceFolder”的文件夹内。所以我认为服务器寻找index.php并找不到它。为什么DirectoryIndex index.php index.html不起作用?
1
A
回答
1
您的DirectoryIndex
指令很好,但您需要将请求路由到正确的文件夹。
有这样的代码在根目录的.htaccess:
DirectoryIndex index.php index.html
RewriteEngine On
RewriteRule !^SourceFolder/ SourceFolder%{REQUEST_URI} [L,NC]
1
因此,您网站的默认“根”目录中有一个名为SourceFolder的文件夹,并且index.php文件在那里?
如果是这样,那么只需在htaccess中执行以下操作。
DirectoryIndex SourceFolder/index.php
这将在SourceFolder中寻找index.php。
相关问题
- 1. DirectoryIndex不起作用
- 2. DirectoryIndex忽略index.php
- 3. 为什么index.html优先于index.php?
- 4. 什么时候用index.php代替index.html
- 5. 为什么Nginx重写一切到index.php,不起作用?
- 6. .htaccess重定向到index.html和index.php不能一起工作
- 7. 为什么不是index.php正常工作?
- 8. :不起作用,为什么?
- 9. 为什么PHP包含不起作用?
- 10. 为什么空字节不起作用?
- 11. 为什么jQuery .load()不起作用?
- 12. 这个XSS为什么不起作用?
- 13. 浮动不起作用。为什么?
- 14. 为什么这个.htaccess不起作用?
- 15. UIBarButtonItem操作不起作用。为什么?
- 16. cron作业不起作用。为什么?
- 17. 给index.html优先index.php
- 18. 为什么SDL_image不起作用
- 19. 为什么servername:port不起作用为什么node.js中的localhost:port起作用?
- 20. Index.php工作,而Index.html不适用于WAMP上的本地主机
- 21. Grunt服务index.php而不是index.html
- 22. .htaccess-如何让index.php和index.html一起工作?
- 23. 优先的index.html的index.php文件在.htaccess
- 24. 隐藏URL的index.php(或index.html)
- 25. 为什么子链接不起作用?
- 26. 为什么AJAX呼叫不起作用?
- 27. 为什么isalpha()不起作用?
- 28. 为什么@autoreleasepool不起作用
- 29. 为什么ng-show不起作用?
- 30. 信号量为什么不起作用?