mod_rewrite all /something to index.html

时间:2021-04-05 11:18:51

I'm trying to rewrite all urls of the following pattern: http://example.com/csfdg/anything into http://example.com/csfdg/index.html

我正在尝试将以下模式的所有url重写到http://example.com/csfdg/anything中:http://example.com/csfdg/index.html

my .htaccess file at the root level contains this:

我的根级.htaccess文件包含以下内容:

Options +FollowSymLinks

RewriteEngine On
RewriteRule \/csfdg\/.* /csfdg/index.html [L]

The checker at http://htaccess.madewithlove.be/ tells me that it would rewrite my URLs the way I want, but when I go to http://example.com/csfdg/anything I just get a 404. It's very hard to tell what's going on, but I know that the RewriteEngine is working because if I mess with it enough I can get 500 errors to happen :)

检验员在http://htaccess.madewithlove。be/告诉我它会按照我想要的方式重写我的url,但是当我访问http://example.com/csfdg/any时,我只会得到404。很难知道发生了什么,但我知道RewriteEngine正在工作,因为如果我对它做了足够的处理,我就会有500个错误发生。

Any thoughts? Thanks

任何想法吗?谢谢

1 个解决方案

#1


3  

You can use this :

你可以用这个:

RewriteEngine on
RewriteCond %{REQUEST_URI} !index\.html$
RewriteRule ^([^/]+)/.+$ /$1/index.html [L]

RewriteConditon is important here to avoid rewriting /foo/index.html to itself.

RewriteConditon在这里很重要,可以避免重写/foo/index。html本身。

#1


3  

You can use this :

你可以用这个:

RewriteEngine on
RewriteCond %{REQUEST_URI} !index\.html$
RewriteRule ^([^/]+)/.+$ /$1/index.html [L]

RewriteConditon is important here to avoid rewriting /foo/index.html to itself.

RewriteConditon在这里很重要,可以避免重写/foo/index。html本身。