1
我這個項目的結構 如何在htaccess中編寫重寫規則以允許訪問項目中的另一個文件夾?
我保存圖像的文件夾數據/圖像。 我想允許通過直接鏈接訪問此文件夾。 我的.htaccess是
RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::$
RewriteRule ^(.*)$ - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
怎麼辦?
您的網站根目錄是「* public *」文件夾嗎?在這種情況下,您無權訪問,因爲它在層次結構中更高。如果可以通過* HTTP *訪問其內容,則必須將圖像文件夾移動到公用文件夾中。然後,您可以使用像「RewriteCond%{REQUEST_URI}」/ images /「'這樣的規則來允許訪問。 – insertusernamehere
如果'data/images'低於您的文檔根目錄,您的規則已經足夠。 –
是的,web根目錄是公共文件夾 – BILL