开发者

what's the rewrite rule meaning? [closed]

开发者 https://www.devze.com 2023-03-22 02:15 出处:网络
Closed. This question is off-topic. It is not currently accepting answers. 开发者_JS百科 Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed. This question is off-topic. It is not currently accepting answers. 开发者_JS百科

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 11 years ago.

Improve this question
RewriteEngine on    

RewriteRule ^(.*)$ http://$1 [R=301,L]

what's the meaning of this line ( RewriteRule ^(.*)$ http://$1 [R=301,L] ). thank you.


It's a 301 (permanent) redirect from whatever path that is on to the relative domain name:

http://<your website>.com/example.com will redirect to http://example.com.

RewriteRule ^(.*)$ http://$1 [R=301,L]

It is literally saying, "Ok, everything found in this folder should be considered permanently redirected to that domain".

  • ^(.*)$ means select everything and call it $1
  • http://$1 means Go to domain stored in $1
  • R=301 refers to status code 301, the "permanently moved" redirect.
  • L means that this is the final instruction for anything matching that pattern. No other redirect rule after this one will effect these redirects.


$1 is the first argument in the rule given
sameway $2 is the second etc

Genrally it is used to take slug from your url

RewriteRule ^(.*)$ http://xyz.com/$1 [R=301,L]

it will do like reditect http://abc.com/post tohttp://xyz.com/post`

301 - stands for permanent redirection
L - shows that this is last rule to .htaccess


This specific rewrite rule will redirect the following URL:

http://site.com/anothersite.com

to..

http://anothersite.com/

.. with a status of 301, which means Permanent Redirection.


You can learn about what RewriteRules do inside the Apache Manual. I only write this, because the meaning of something is related to it's technical understanding.

If you are interested in what my meaning of the following is:

RewriteRule ^(.*)$ http://$1 [R=301,L]

It's a redirect to another location in the internet, a permanent redirect. Test it, it works!

0

精彩评论

暂无评论...
验证码 换一张
取 消