我使用htaccess重写我的网址首先一个正常工作
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ /oneday/index.php?do=$1 [L,QSA]
重写url但现在我想访问我的子目录,我的目录就像这个Oneday/files/pdf-generation/dock-receipt-PDF24032015.pdf
一样存在,为此我的代码是
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\?*$ /oneday/files/pdf-generation/path$1
我的完整代码htaccess是
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ /oneday/index.php?do=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\?*$ /oneday/files/pdf-generation/path$1
但第二个不适合我。我怎么能这样做,Oneday
是我的项目目录名。
现在,第一个网址创建此链接http://localhost/oneday/bookings
,现在我想访问我的PDF
个文件http://localhost/oneday/files/pdf-generation/dock-receipt-PDF03242015.pdf
答案 0 :(得分:1)
您只能为现有文件定位第二条规则:
RewriteEngine On
RewriteBase /Oneday/
RewriteCond %{DOCUMENT_ROOT}/Oneday/files/pdf-generation/path/$1 -f [NC]
RewriteRule ^(.+)$ files/pdf-generation/path/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?do=$1 [L,QSA]