重写路径使用htaccess的一个特定的文件重写、路径、文件、htaccess

由网友(往后余生)分享简介:我想创造一个友好的URL从具有长文件路径,以及重命名文件的目​​录中的特定文件。我甚至不知道这是可能的。 I would like to create a friendly url for a specific file from a directory that has a long file path as we...

我想创造一个友好的URL从具有长文件路径,以及重命名文件的目​​录中的特定文件。我甚至不知道这是可能的。

I would like to create a friendly url for a specific file from a directory that has a long file path as well as renaming the file. I am not even sure if this is possible.

到目前为止,我曾尝试在htaccess的:

So far I have tried in htaccess:

RewriteEngine On 
Options +FollowSymLinks
RewriteRule eventdays-2012/brochure.pdf(.+)$ sites/default/files/docs/fact_sheet-204499207.pdf

...但是这是行不通的。

... but this is not working.

我已经做了一些搜索,看看你能掩盖整个目录中的文件路径,但在我来说,我只想做一个文件的目录中,创建一个目录名和更改文件名也是如此。

I've done some searching and see where you can mask an entire directory in the file path but in my case I just want to do one file within the directory, create a directory name and change the file name as well.

推荐答案

尝试删除(+)部分从常规的前pression。它使得你的需要的东西AFTE rthe brochure.pdf 。另外补充一些界限:

Try removing the (.+) part from your regular expression. It makes it so you need something afte rthe brochure.pdf. Also add some boundaries:

RewriteEngine On 
Options +FollowSymLinks
RewriteRule ^/?eventdays-2012/brochure.pdf$ /sites/default/files/docs/fact_sheet-204499207.pdf [L]
阅读全文

相关推荐

最新文章