如何使用.htaccess创建回退URL并将其与其他规则集成
我有一个这样的目录结构如何使用.htaccess创建回退URL并将其与其他规则集成,.htaccess,.htaccess,我有一个这样的目录结构 .../htdocs/domain/example/ <==> http://example.com/home/ .../htdocs/domain/example1/ <==> http://example1.com/home/ .../htdocs/domain/example2/ <==> http://example2.com/home/ 我想请求 http://example.com/home/logo.
.../htdocs/domain/example/ <==> http://example.com/home/
.../htdocs/domain/example1/ <==> http://example1.com/home/
.../htdocs/domain/example2/ <==> http://example2.com/home/
我想请求
http://example.com/home/logo.jpg ==> .../htdocs/domain/example/logo.jpg
BUT if the file doesn't exist it should return
==> .../htdocs/domain/default/logo.jpg
回答我自己的问题 我在/htdocs/domain中添加了这个.htaccess文件/
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z]+)/(.*)$ /default/$2 [L]
我基本上是说,如果遇到找不到的文件,请尝试使用/default
我发现如果我将默认内容放在/htdocs/domain中,那么我就创建了一个递归问题,所以我只将它们放在/htdocs/default中
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z]+)/(.*)$ /default/$2 [L]