简体   繁体   English

.htaccess文件以重定向除wp-admin仪表板以外的所有页面

[英].htaccess file to redirect all pages except the wp-admin dashboard

I have redirected the all pages of my wp site from .php extension to / For example, I am redirect pages such as example.com/about-us.php to example.com/about-us/ but, It is also redirecting my example.com/wp-admin dashboard page which I don't want to redirect.How can I prevent it from redirecting? 我已经将wp网站的所有页面都从.php扩展名重定向到/例如,我将诸如example.com/about-us.php之类的页面重定向至example.com/about-us/,但是,这也正在重定向我的我不想重定向的example.com/wp-admin信息中心页面。如何防止其重定向? Here is my .htaccess code. 这是我的.htaccess代码。

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

# redirect to .php-less link if requested directly
RewriteCond %{THE_REQUEST} ^[A-Z]+\s.+\.php\sHTTP/.+
RewriteRule ^(.+)\.php $1 [R=301,L]

Are you sure you want the 301 redirect ( R=301 )? 您确定要301重定向( R=301 )吗? Surely you want the URL to look like it doesn't have .php but under the hood you still want to access the respective php script? 当然,您希望URL 看起来没有.php,但是在后台您仍然想访问相应的php脚本?

Anyway, how about this - two conditions: 无论如何,这有两个条件:

  1. must not have wp- in the request URI 请求URI中不得包含wp-
  2. must end in .php 必须以.php

Like this: 像这样:

RewriteCond %{REQUEST_URI} !wp-
RewriteCond %{REQUEST_URI} \.php$
RewriteRule ^(.+)\.php $1 [R=301,L,QSA]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM