重定向后的.htaccess隐藏子目录网址 [英] .htaccess hide subdirectory url after redirect

查看:621
本文介绍了重定向后的.htaccess隐藏子目录网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我重定向一个网站,我创建了一个子目录。该子目录包含安装的话语preSS,现在我想掩盖从网站子目录中的网址。

I'm redirecting a website to a subdirectory I created. The subdirectory contains an installation of WordPress and now I want to mask the subdirectory url from the website.

现在它的东西,如 http://mywebsite.com/apt/

我想从URL中删除/公寓/。

I want to remove the /apt/ from the URL.

我什么都试过今天,搜索在谷歌,试着写各种各样的事情上,我发现这里的htaccess,但没有什么工作。

I tried everything today, searched on Google, tried to write various things on the htaccess I found here but nothing works.

在对网站的主目录下的htaccess的,我用这个code重定向

On the htaccess on the main directory of the site, I use this code to redirect

RewriteCond %{HTTP_HOST} ^mywebsite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mywebsite.com$
RewriteRule ^/?$ "http\:\/\/www\.mywebsite\.com/\apt" [R=301,L] 

和上一个在/公寓/文件夹,我有

And on the one in the /apt/ folder I have

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /apt/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /apt/index.php [L]

</IfModule>

# END WordPress

可能有人建议我怎么能隐藏/公寓/扩展名的网址是什么? 非常感谢。

Could someone suggest me how can I hide the /apt/ extension from the URL? Thanks a lot.

推荐答案

试试这个: 删除重定向的部分,然后用这个INSEAD:

Try with this: remove the redirect part then use this insead:

RewriteCond %{THE_REQUEST} ^GET\ /apt/
RewriteCond %{HTTP_HOST} ^(www\.)?mysite.com$
RewriteRule ^apt/(.*) /$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?mysite.com$
RewriteRule !^apt/ apt%{REQUEST_URI} [L]

然后用同样的code为主要的网站。

then use the same code for the main website.

这篇关于重定向后的.htaccess隐藏子目录网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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