2

I'm trying to remove /uploads from a url. I have followed many examples but none of them work.

I think this one is the closest and should actually work but nothing is happening.

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

here is what I have in the 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]

I should go from: http://example.com/storage/uploads/droom.pdf To: http://example.com/storage/droom.pdf

1 Answer 1

1

Try replacing this line:

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

with this:

RewriteRule ^(.*?)/?uploads(.*)$ /$1$2 [L]
Sign up to request clarification or add additional context in comments.

1 Comment

oh ofcourse, it didn't start with /uploads .. and .* is better then .+ i guess? Is working now, thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.