【问题标题】:Rewrite part of url .htacces重写部分 url .htaccess
【发布时间】:2012-10-29 12:04:05
【问题描述】:

我需要从

重定向一个网址

http://mydomain.com/download/文件名.zip

https://dl.dropbox.com/u/0000/文件名.zip

如何使用 mod_rewrite 做到这一点?

【问题讨论】:

    标签: mod-rewrite


    【解决方案1】:

    使用以下规则在您的第一个域的根目录中创建一个.htaccess 文件:

    RewriteEngine On
    RewriteRule download/(.+) https://dl.dropbox.com/u/0000/$1 [L,R=301]
    

    【讨论】:

      【解决方案2】:
          # Check to see if mod_rewrite is installed / avaliable
      <IfModule mod_rewrite.c>
      RewriteEngine on
      
      # Check to see if file or directory exists
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      
      # Rewrite to Dropbox URL. Make sure you change the data after "/u/" (9502594) to your own user ID
      RewriteRule ^e/(.*)$ http://dl.dropbox.com/u/9502594/$1 [L,QSA]    # Embedded File
      RewriteRule ^(.*)$ http://dl.dropbox.com/u/9502594/$1?dl=1 [L,QSA] # Force Download (Default)
      </IfModule>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多