当前位置:网站首页>设置Wordpress伪静态连接(无宝塔)
设置Wordpress伪静态连接(无宝塔)
2022-07-06 18:01:00 【挚夏】
设置Wordpress伪静态链接
Apache2.4
本文是不在使用宝塔的情况下自行设定的, 有安装宝塔的请忽视
环境:Ubuntu20.04 Apache2.4 Wordpress5.9.2
重写规则
开启重写规则
sudo a2enmod rewrite
设置根目录重定向
sudo vim /etc/apache2/apache2.conf
找到
<Directory /var/www/>
将
AllowOverride
后的None
修改为ALL
。进入Wordpress后台选择自己喜欢的伪静态,并点击保存,自动生成
.hatccess
规则并复制,如下:<IfModule mod_rewrite.c> RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteRule ^^unsubscribe-comment-mailnotice/?(.*)$ //wp-con> RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
- 在刚刚的
/var/www/
目录下(即网站的根目录) 创建.hatccess
文件
粘贴刚刚复制的规则代码并保存。
- 在刚刚的
重启服务器即可
sudo systemctl restart apache2
效果图
Nginx1.19
本文是不在使用宝塔的情况下自行设定的, 有安装宝塔的请忽视
环境:Raspi OS 64bit(Debian11) Wordpress5.9.2
打开配置文件sudo vim /etc/nginx/sites-available/default
如果wordpress安装在网站根目录,在server中添加
location / {
if (!-e $request_filename) {
rewrite (.*) /index.php;
}
}
如果wordpress安装在网站二级目录,在server中添加:
location /二级目录/ {
if (!-e $request_filename) {
rewrite (.*) /cn/index.php;
}
}
重启sudo /etc/init.d/ngnix restart
在wordpress后台设置需要的固定链接即可
边栏推荐
猜你喜欢
Byte P7 professional level explanation: common tools and test methods for interface testing, Freeman
The MySQL database in Alibaba cloud was attacked, and finally the data was found
Comparison of picture beds of free white whoring
Analysis of mutex principle in golang
According to the analysis of the Internet industry in 2022, how to choose a suitable position?
2022 Google CTF SEGFAULT LABYRINTH wp
【信号与系统】
Let's see through the network i/o model from beginning to end
Lldp compatible CDP function configuration
C language - array
随机推荐
What are the differences between Oracle Linux and CentOS?
Analysis of mutex principle in golang
c语言—数组
JS reverse -- ob confusion and accelerated music that poked the [hornet's nest]
2022 Google CTF segfault Labyrinth WP
Taro2.* applet configuration sharing wechat circle of friends
C语言实例_4
DS-5/RVDS4.0变量初始化错误
How to evaluate load balancing performance parameters?
Oracle: Practice of CDB restricting PDB resources
今日问题-2022/7/4 lambda体中修改String引用类型变量
Body mass index program, entry to write dead applet project
让我们,从头到尾,通透网络I/O模型
Installation and testing of pyflink
Js逆向——捅了【马蜂窝】的ob混淆与加速乐
Sword finger offer II 035 Minimum time difference - quick sort plus data conversion
What does front-end processor mean? What is the main function? What is the difference with fortress machine?
POJ 3177 Redundant Paths POJ 3352 Road Construction(双连接)
Lldp compatible CDP function configuration
Gazebo的安装&与ROS的连接