【发布时间】:2021-10-04 10:44:56
【问题描述】:
不知道为什么我的 .htaccess 文件没有做它应该做的关于 mod_rewrite 的事情。
mod_rewrite 已启用,并且我相信目录路径具有正确的指令。
<Directory /var/www/html/test>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
在 ubuntu 20.04 上运行 apache2
这是我当前的 .htaccess 文件:
RewriteEngine on
RewriteCond %{THE_REQUEST} /test/_plugin/accounts/ [NC]
RewriteRule ^test/_plugin/accounts/(.*)$ /test/accounts/$1 [L,R]
RewriteRule ^test/accounts/(.*)$ /test/_plugin/accounts/$1 [L]
我在这里想要完成的是:
- 保留
/test/_plugin/accounts/的内容并显示该内容以将URL 重写为/test/accounts/,其中/test/accounts/目录实际上并不存在。
对此的任何帮助将不胜感激
【问题讨论】:
-
究竟是什么不工作?
-
404 Not Found...我猜是因为
/test/accounts/实际上并不存在。有没有办法将内容从/test/_plugin/accounts/复制到/test/accounts/而/test/accounts/实际上存在重写? -
这个 htaccess 文件位于哪个文件夹?
-
它位于
/test/文件夹中
标签: .htaccess mod-rewrite url-rewriting apache2 ubuntu-20.04