我在项目中有一个 wordpress 网站,我想屏蔽所有页面的 URL,以便在访问它们时:
https://myweb.com/survey/page1
https://myweb.com/survey/page2
....
显示为:
https://myweb.com/survey/portal
我在 .htaccess 上有这个,但它不起作用:
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /survey/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /survey/index.php [L]
RewriteRule ^survey/?$ /survey/portal/
谢谢大家的宝贵时间。
最佳答案
首先是非常好的努力,请您尝试以下;根据您显示的示例编写。请在测试您的 URL 之前清除您的浏览器缓存。
另请将您的 .htaccess 文件置于 survey
文件夹的上一层。
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /survey/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ https://%{HTTP_HOST}/portal [R=301]
RewriteRule ^ survey/index.php [L]
关于apache - 在 htaccess 中屏蔽 URL 重写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66261721/