Apache的URL重写 - 试图掩盖的文件夹名称 [英] Apache URL rewrite - Trying to mask the folder name

查看:120
本文介绍了Apache的URL重写 - 试图掩盖的文件夹名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有位于 example.com/cmsFolder 一个网站,我想搬到 example.com/newFolder 。我不能手动移动这个,因为它完全打破了这个愚蠢的CMS。

I have a website located at example.com/cmsFolder which I want to move to example.com/newFolder. I can't manually move this as it completely breaks this stupid CMS.

所以我想用的mod_rewrite 来掩盖文件夹名称,并保持它在寻找好的。

So I'm trying to use mod_rewrite to mask the folder name and keep it looking nice.

RewriteEngine on
RewriteRule ^cmsFolder/(.*)$ /newFolder/$1 [L]

这是失败,一个404我怎么能掩盖该文件夹的名字吗? :/

That fails with a 404. How can I mask the folder name? :/

推荐答案

试试这个,这为我的作品,同时增加本规则Apache的主配置文件:

Try this, It works for me while adding this rules to Apache's main configuration file:

RewriteEngine on
RewriteRule ^/cmsFolder/(.*)$ /newFolder/$1 [L]

我想你忘记了第一个斜线cmsFolder之前。如果你想看看mod_rewrite的日志:

I think you forgot first slash before cmsFolder. If you want to look at mod_rewrite logs:

RewriteLog "_PATH_TO_YOUR_\rewrite.log"
RewriteLogLevel 9

由于保罗评论日志指令不.htacces不允许的。原因不难理解: - )

As Paolo comments log directives are not allowed in .htacces. Easy to understand why :-)

编辑:

也许,如果你想掩盖你将使用请求[P]修饰符(代理):

Probably if you want to mask the request you will use [P] modifier (Proxy):

RewriteEngine on
RewriteRule ^/cmsFolder/(.*)$ /newFolder/$1 [P]

这篇关于Apache的URL重写 - 试图掩盖的文件夹名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆