如何从URL与htaccess的重写删除该目录/文件夹?重写、文件夹、目录、URL

2023-09-02 09:37:01 作者:智商已欠费

我的宗旨是:

domain.com/folder

改写 - >

rewrite ->

domain.com

这将涉及到该站点内的所有链接。 我的意思是在网站上就像链接:

this shall concern ALL links inside that site. I mean on the site are links like:

domain.com/folder/forum.html
domain.com/folder/community.html

等。

这是我的目标:

domain.com/forum.html
domain.com/community.html

等。

和它的文件夹是从来没有在url中adressbar非常重要可见。

and its very important that the "folder" is never in the url in the adressbar visible.

我已经试过很多codeS,但我不能真正解决这个问题。 我最好的尝试是这个code:

I tried already many codes but I couldnt really solve this problem. My best try was with this code:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !(.*)folder
RewriteRule ^(.*)$ folder/$1 [L]

如果我输入

 domain.com 

我得到的含量

I get the content of

 domain.com/folder

显示,什么是正确的(夹不是在所示的URL)。但是,当我点击网站像的一些链接:domain.com/folder/community.html那么我可以再次看到文件夹中的URL,但我想让它变得总是删除

displayed, what is correct ("folder" is not in the url shown). But when i click on some links of the site like: domain.com/folder/community.html then I can see again "folder" in the url, but I want that it becomes ALWAYS removed.

这里是我的地盘:

thewedgiecommunity.x10.mx/wedgiecommunity/

我的目的是去除wedgiecommunity(=文件夹) 此链接工作

My aim is to remove the "wedgiecommunity" (=folder) This link is working

  thewedgiecommunity.x10.mx/

但是,当你点击共同体(

But when you click on Community (

 thewedgiecommunity.x10.mx/wedgiecommunity/community.html

),然后我又得到了URLwedgiecommunity。

) then i get again "wedgiecommunity" in the URL.

将是真棒如果有人可以帮助我

Would be awesome when someone could help me

推荐答案

您可以使用此code:

You can use this code:

进去DOCUMENT_ROOT / wedgiecommunity / htaccess的:

RewriteEngine On

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s/+wedgiecommunity([^s]*) [NC]
RewriteRule ^ %1 [R=301,L]

进去DOCUMENT_ROOT / htaccess的:

RewriteEngine On

RewriteRule !^/?wedgiecommunity wedgiecommunity%{REQUEST_URI} [L,NC]