2012-08-08 57 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