重定向后的.htaccess隐藏子目录网址子目录、重定向、网址、htaccess

2023-09-02 09:46:23 作者:视你如命

我重定向一个网站,我创建了一个子目录。该子目录包含安装的话语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.