【发布时间】:2020-01-09 11:34:44
【问题描述】:
我想在 URL 中屏蔽一个文件夹,所以 www.mysite.com /employers/university-of-worcester/profile.html 将是 www.mysite.com /university-of-worcester/profile.html ,这意味着子目录“employers”是隐藏的。
在“employers”文件夹中会创建很多文件夹。
这是修改.htaccess的问题,我尝试了很多我在堆栈上找到的解决方案。
我尝试添加的最新代码行是:
RewriteRule ^employers/(.*)$ /$1 [L]
我的 .htaccess 现在看起来像这样:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^employers/(.*)$ /$1 [L]
</IfModule>
如果我转到 URL www.mysite.com/employers/ 这将重定向到 www.mysite.com/(主页),我对此很满意,但如果我尝试 www.mysite.com/university-of -worcester/profile.html 我得到“找不到页面。”,但主页 profile.html 肯定在“伍斯特大学”文件夹中。
我正在使用 wordpress。
【问题讨论】:
标签: .htaccess url subdirectory