我正在使用htaccess重写我的url,第一个现在运行良好
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是我的项目目录名。
现在,首先url创建这个链接http://localhost/oneday/bookings,现在我想访问我的PDF文件http://localhost/oneday/files/pdf-generation/dock-receipt-PDF03242015.pdf
发布于 2015-03-24 15:15:43
您只能针对现有文件的第二条规则:
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]https://stackoverflow.com/questions/29236220
复制相似问题