Apache 使用.htaccess文件使子目录独立

Apache 使用.htaccess文件使子目录独立,apache,.htaccess,web,subdirectory,Apache,.htaccess,Web,Subdirectory,假设我在www文件夹中有一个子目录,名为subdirectory。是否可以修改.htaccess文件,以便子目录中包含的所有文件都可以在其他文件中引用,例如:/somefile.extension?因此,我希望子目录充当其中所有文件的根目录,而不希望使用子域。尝试以下操作: RewriteEngine on RewriteCond %{HTTP_REFERER} ^http://site.com/subdirectory/ RewriteCond %{REQUEST_URI} !^/subdir

假设我在
www
文件夹中有一个子目录,名为
subdirectory
。是否可以修改
.htaccess
文件,以便子目录中包含的所有文件都可以在其他文件中引用,例如:
/somefile.extension
?因此,我希望子目录充当其中所有文件的根目录,而不希望使用子域。

尝试以下操作:

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://site.com/subdirectory/
RewriteCond %{REQUEST_URI} !^/subdirectory/
RewriteRule (.*) /subdirectory/$1 [L,QSA]