简体   繁体   English

从URL中删除目录

[英]Remove directory from URL

I want to remove a directory from my homepage link 我想从我的主页链接中删除目录

example.com/remove/ to example.com example.com/remove/到example.com

thing is, the index is located in the "remove" directory. 事实是,索引位于“删除”目录中。

I've tried: RewriteRule ^front /(.*)$ /$1 [L,R=301] 我试过了: RewriteRule ^front /(.*)$ /$1 [L,R=301]

But this produced an internal server error 但这会产生内部服务器错误

If you have access to httpd.conf change this in httpd.conf 如果你有权访问httpd.confhttpd.conf更改它

DocumentRoot "C:/xampp/htdocs/remove"

If you are running xampp or having a linux setup you will find httpd.conf in conf folder which is having below line in which you have to add your remove directory which will be your new root directory then every call to example.com will forwarded to example.com/remove . 如果您正在运行xampp或进行Linux设置,您将在conf文件夹中找到httpd.conf,该文件夹位于以下行,您必须添加您的删除目录,这将是您的新根目录,然后每次调用example.com都会转发到example.com/remove

And then restart your server. 然后重新启动服务器。

Or if not use this in .htaccess 或者如果不在.htaccess使用它

DirectoryIndex index.html

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM