2012-08-08 46 views
2

我正尝试从网址中删除/上传。我遵循了很多例子,但没有一个能够工作。重写网址,删除网段

我认为这一个是最接近的,应该实际工作,但没有发生。

RewriteRule ^/uploads/(.+)$ /$1 [QSA] 

这里是我的htaccess的

# Enable URL rewriting for pretty URLs 

php_flag magic_quotes_gpc off 

<FilesMatch "\.(?i:pdf)$"> 
    ForceType application/octet-stream 
    Header set Content-Disposition attachment 
</FilesMatch> 

RewriteEngine on 
RewriteBase/
RewriteRule ^/uploads/(.+)$ /$1 [QSA] 

RewriteRule !\.(php|js|ico|gif|jpg|png|css|html|cgi|pdf|doc|xls|docx|xlsx|ppt|tff|svg|eot|woff|swf|mp3|wma|wav|MP4|AIFF|AAC|m4a|m4p|AVI|MOV|MPG|MPEG)$ index.php [NC] 
#RedirectMatch ^/$ /misc/offline.php [NC] 

我应该去从: http://example.com/storage/uploads/droom.pdf 要: http://example.com/storage/droom.pdf

回答

1

尝试更换这行:

RewriteRule ^/uploads/(.+)$ /$1 [QSA] 

与硫s:

RewriteRule ^(.*?)/?uploads(.*)$ /$1$2 [L] 
+0

oh of course,it does not start with/uploads .. and。* is better then。+ i guess?现在在工作,谢谢。 – Christophe 2012-08-08 10:09:33