Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用htaccess访问我的子目录_Php_.htaccess - Fatal编程技术网

Php 使用htaccess访问我的子目录

Php 使用htaccess访问我的子目录,php,.htaccess,Php,.htaccess,我正在使用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/doc

我正在使用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-receive-pdf2402015.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
但第二个对我不起作用。我怎样才能做到这一点,
一天
是我的项目目录名


现在,第一个url创建此链接
http://localhost/oneday/bookings
现在我想访问我的
PDF
文件
http://localhost/oneday/files/pdf-generation/dock-receipt-PDF03242015.pdf

您只能针对现有文件的第二条规则:

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]

我更正了我问题中的代码。您好
anubhava先生
您的代码对我无效。我的url是
http://localhost/oneday/bookings
当我单击锚定标记的“显示”弹出窗口,然后单击“在”按钮,然后url显示在另一个选项卡中时
http://localhost/onedayfiles/pdf-generation/dock-receipt-PDF03242015.pdf
错误是
找不到页面对不起!您请求的页面不存在,或者您可能没有足够的权限查看它。单击此处进入主页。
这是我的书写错误。我再次检查了它,但错误相同。
http://localhost/oneday/
这是我的项目目录路径和
http://localhost/oneday/files/pdf-generation/dock-receipt-dock-receipt-PDF24032015.pdf
这是我的完整路径。让我们来看看。