Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache重写,主页_Apache_Url_Mod Rewrite - Fatal编程技术网

Apache重写,主页

Apache重写,主页,apache,url,mod-rewrite,Apache,Url,Mod Rewrite,我正试图将网站的“主页”改写为www.example.com 现在可以通过www.example.com/dir/userdo?action=home 我的想法是www.example.com实际上是www.example.com/index.html,因为apache自动隐藏/index.html,所以我尝试了 RewriteRule/index.html/dir/user.do?action=home[PT,L] 这是行不通的 有人能给我一个解决这个问题的正确方法吗?谢谢重写规则^/$/di

我正试图将网站的“主页”改写为
www.example.com

现在可以通过
www.example.com/dir/userdo?action=home

我的想法是
www.example.com
实际上是
www.example.com/index.html
,因为apache自动隐藏
/index.html
,所以我尝试了

RewriteRule/index.html/dir/user.do?action=home[PT,L]

这是行不通的


有人能给我一个解决这个问题的正确方法吗?谢谢

重写规则^/$/dir/userdo?action=home[L]


默认index.html可以使用
DirectoryIndex
指令进行更改。

ty,页面现在显示,但是
dir/cssimage
下的所有css、图像加载失败。我检查web控制台,它似乎在请求根文件夹下不存在的
/cssimage
目录。知道哪里出了问题吗?这个重写规则不会影响浏览器认为所有资源应该位于的url/(例如/cssimage)。这里有一些添加规则来修复这个问题,
RewriteCond%{REQUEST\u FILENAME}-f
重写规则^(.*)$/dir/$1[L]
。这些规则将把文件不存在的所有请求重定向到/dir/。