apache - 在 htaccess 中屏蔽 URL 重写

标签 apache .htaccess redirect mod-rewrite url-rewriting

我在项目中有一个 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/

相关文章:

apache - .htaccess文件夹到虚拟文件夹重写

.htaccess - 从 URL 中删除 Yii2 Pagination 中的第一页编号

redirect - Spring Security-Grails 3.2.2-ERR_TOO_MANY_REDIRECTS

apache - httpd 使用 SSL 和子域/虚拟主机重定向

php - Apache /PHP/PHP-FPM : locale settings change themselves

windows - NGINX cmd 命令不起作用

web-services - 防止访问主域上子域的文件夹

java.net.协议(protocol)异常 : Too many redirects: 21 Android App

html - 使用 Apache 上传文件

linux - Apache2 服务器无法启动