我正在尝试让我的 htaccess 重写一些页面,例如 /programme 内容与 /wordpress/programme 中的内容相同 我已经尝试这样做几个小时了,但我无法让它工作(即使我尝试从一些 yt 视频中复制代码)
第一条规则“^/programme$ /wordpress/programme/”似乎不起作用(即使我尝试使用私人导航) 尽管如此,重定向规则工作得很好
有人可以帮助我吗😇? 谢谢你
RewriteEngine On
RewriteRule ^\/programme$ /wordpress/programme/
## http -> https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE,QSA]
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
#
我尝试从在线或 yt 视频上找到的其他 .htaccess 复制文件,以及重定向 WordPress 插件:/ 我想让我的 .htaccess 重写 /programme 中的 URL,如网站在 /wordpress/programme 上显示的那样 😁
将您的代码替换为以下内容:
RewriteEngine On
# Rewrite /programme to /wordpress/programme
RewriteRule ^programme/?$ /wordpress/programme/ [L]
## http -> https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE,QSA]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
进行这些更改后,访问您网站上的 /programme 应显示 /wordpress/programme 中的内容。请务必清除浏览器缓存以测试更改。