Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set 301 jump for .htaccess

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "how to set up 301 jump.htaccess", the content is simple and easy to understand, and the organization is clear. I hope it can help you solve your doubts. Let Xiaobian lead you to study and learn this article "how to set up 301 jump.htaccess".

.htaccess Settings 301 Jump and common tips

In a virtual hosting environment, it is basically an Apache environment. Apache pseudo-static settings are set in the root directory of the website.htaccess file, whether pseudo-static in the.htaccess file,

Or 301 jump, or even anti-theft chain and prohibit access to a certain IP can be very simple settings.

About.htaccess file settings and practical applications are quite extensive, many functions can be used to achieve this small file, but our ordinary users do not use much, such as our commonly used 301 jump to the second level domain name with WWW jump to the top-level domain name without WWW,

Or an anti-theft chain, or prohibit IP and so on. In this article, we will introduce several common uses of.htaccess files.

Domain name: 301

The direct replacement of domain names for their own domain names can achieve non-WWW jump to WWW domain names.

RewriteEngine onRewriteCond %{HTTP_HOST} ^pazzn\.com [NC]RewriteRule ^(.*)$ https://www.pazzn.com/$1 [L,R=301,NC] Force Non-WWW Domain Names 301 Jump

If you visit www domain name prefix, you will jump to non-www domain name, and the domain name will be replaced with its own.

RewriteEngine OnRewriteCond %{HTTP_HOST} !^ pazzn.com$ [NC]RewriteRule ^(.*)$ http://pazzn.com/$1 [L,R=301] forced https jump address

If a website uses SSL Certificates, it generally needs to force a jump to https path. Here, you need to add a jump to force port 80, and the server should also open port 443.

RewriteEngine OnRewriteCond %{SERVER_PORT} 80RewriteRule ^(.*)$ https://www.pazzn.com/$1 [R,L] Stop unwanted spider crawling

RewriteEngine OnRewriteCond %{HTTP_USER_AGENT} (^$|FeedDemon|JikeSpider|Indy Library|Alexa Toolbar|AskTbFXTV|AhrefsBot|CrawlDaddy|CoolpadWebkit|Java|Feedly|UniversalFeedParser|ApacheBench|Microsoft URL Control|Swiftbot|ZmEu|oBot|jaunty|Python-urllib|lightDeckReports Bot|YYSpider|DigExt|HttpClient|MJ12bot|heritrix|EasouSpider|Ezooms) [NC]RewriteRule ^(.*)$ - [F] Redirect Page A 301 to Page B_Redirect 301/a.html https://www.pazzn.com/b.html Redirect all to B RewriteEngine onRewriteRule ^(.*)$ http://www.pazzn.com/$1 [R=301,L] Block an IP from accessOrder deny,allowAllow from allDeny from 127.0.0.1 Mandatory/slash endpath RewriteCond %{REQUEST_URI} /+[^\.]+$ RewriteRule ^(.+ [^/])$ %{REQUEST_URI}/ [R=301,L] cancel/slash ending RewriteCond %{REQUEST_FILENAME} !- dRewriteRule ^(.*)/$ /$1 [R=301,L] Forbidden SetEnvIf Request_URI "/starry-night" allow_framing=trueHeader set X-Frame-Options SAMEORIGIN env=! allow_framing RewriteEngine onRewriteCond %{HTTP_REFER} !^$ RewriteCond %{HTTP_REFERER} !^ http(s)?:// (.+\.)? feiniaomy.com [NC]RewriteRule \. (jpg|png| gif| bmp)$ - [NC,F,L] The above is ".htaccess How to set 301 jump" All the contents of this article, thank you for reading!| bmp)$ - [NC,F,L]以上是".htaccess如何设置301跳转"这篇文章的所有内容,感谢各位的阅读! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report