更新时间:2023-11-23 09:56:40
如果根 .htaccess
文件仅包含mod_rewrite指令,则可以完全覆盖根 .htaccess
只需在/subfolder/.htaccess
中启用重写引擎即可.
If the root .htaccess
file only contains mod_rewrite directives then you can completely override the root .htaccess
file by simply enabling the rewrite engine in /subfolder/.htaccess
.
例如:
RewriteEngine On
PassengerAppRoot "/home/username/djangoapplication"
PassengerPython "/home/username/virtualenv/webapp/2.7/bin/python2.7"
默认情况下,默认情况下不继承mod_rewrite指令 (与其他模块不同).但是,可能已在服务器配置中专门启用了mod_rewrite继承,所以这可能行不通.
By default, mod_rewrite directives are not inherited by default (unlike other modules). However, it is possible that mod_rewrite inheritance has been specifically enabled in your server config, so this may not work.
如果这不起作用,则需要在根 .htaccess
文件的顶部创建一个例外,以防止请求/subfolder/
覆盖.例如:
If this doesn't work then you would need to create an exception at the top of the root .htaccess
file, that prevents requests for the /subfolder/
being overridden. For example:
RewriteRule ^subfolder - [L]
当URL以/subfolder
开头时,这会停止在 .htaccess
根文件中进行任何进一步的处理.
This stops any further processing in the root .htaccess
file when the URL starts with /subfolder
.