的.htaccess:重写规则问题,如何重定向所有管理面板

编程入门 行业动态 更新时间:2024-10-20 20:45:13
本文介绍了的.htaccess:重写规则问题,如何重定向所有管理面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我要重定向我的网站管理面板

I want to redirect my website to admin panel

如同

localhost/website/ => localhost/website/admin localhost/website/login => localhost/website/admin localhost/website/blog => localhost/website/admin

下面是我创建的规则

RewriteEngine on RewriteCond $1 !^(index\.php) RewriteRule ^(.*)$ /website/admin/$1 [L]

不过,这是行不通的。

But this is not working

推荐答案

以下code将一切重新定向到您的管理页面,保留的属性。这也适用于已经存在的文件谁!

The following code will redirect everything to your admin page, keeping the attributes. This also applies to files who already exist !

RewriteEngine On RewriteCond %{REQUEST_URI} !^website/admin #RewriteCond %{REQUEST_FILENAME} !-f #OPTIONAL: Remove '#' if you want existing files to display normally #RewriteCond %{REQUEST_FILENAME} !-d #OPTIONAL: Remove '#' if you want existing files to display normally RewriteRule ^(.*)$ /website/admin/ [L,QSA]

说明:

打开重写引擎:

Explanation:

turn on the rewrite engine:

RewriteEngine On

改写特定条件:URI(域名/本地主机之后的部分)不能(=逆,不!)启动(^ =起始行)与网​​站/系统管理员 =你在哪里重写。这必须完成,以prevent循环。

specific condition for rewriting: uri (the part after your domain name/localhost) cannot (! = inverse, NOT) start (^ = start of line) with website/admin = where you are rewriting to. This must be done to prevent looping.

RewriteCond %{REQUEST_URI} !^website/admin

随着2号线可以去掉(删除#),如果你想现有的文件不会被重写

Following 2 lines can be uncommented (remove the #) if you want that existing files are not rewritten

#RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d

在改写自己:

The rewrite himself:

  • ^ =行首
  • ()=子串
  • 。* =一些任意的符号,或无符号
  • $ =行尾
  • /网站/管理=的地方重写
  • [L,QSA] =额外的选项:
  • L =最后:停止执行更多的行
  • QSA =查询字符串附加:保持参数,如?页=接触例如。

  • ^ = start of line
  • () = a substring
  • .* = a number of arbitrary symbols, or no symbols
  • $ = end of line
  • /website/admin = the place to rewrite to
  • [L,QSA] = extra options:
  • L=last: stop executing further lines
  • QSA=Query String Append: keep arguments, e.g. ?page=contact e.g.

重写规则^(。*)$ /网站/管理/ [L,QSA]

我希望这澄清了我的解决方案。

I hope this clarifies my solution.

更多推荐

的.htaccess:重写规则问题,如何重定向所有管理面板

本文发布于:2023-11-01 18:05:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550031.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   重定向   面板   规则   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!