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

编程入门 行业动态 更新时间:2024-10-21 16:16:15
本文介绍了如何从URL与htaccess的重写删除该目录/文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的宗旨是:

domain/folder

改写 - >

rewrite ->

domain

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

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

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

等。

这是我的目标:

domain/forum.html domain/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

我得到的含量

I get the content of

domain/folder

显示,什么是正确的(夹不是在所示的URL)。但是,当我点击网站像的一些链接:domain/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/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]

更多推荐

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

本文发布于:2023-11-01 20:15:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550303.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   文件夹   目录   URL   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!