.htaccess redirect without changing address bar

后端 未结 1 1441
南笙
南笙 2020-12-01 12:32

I\'m trying to write an .htaccess rule to redirect to a script, which further redirects somewhere else. Kind of like how URL shorteners work. However, I

相关标签:
1条回答
  • 2020-12-01 13:02

    If you are using the R flag you are telling mod_rewrite that an external redirect is what you want, therefore the browser is asked to make a new request and the address bar should change accordingly.

    Without the R flag, there is no redirect, but an Apache-internal request rewrite which is hidden from the browser. Thus, the address bar won't change. However, you cannot use internal redirects to external URIs for obvious reasons.

    Since you seem to use an internal redirect anyway, just remove the R flag and it should work:

    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule (.+)$ ?url=$1 [L]
    
    0 讨论(0)
提交回复
热议问题