简体   繁体   中英

Remove directory from URL

I want to remove a directory from my homepage link

example.com/remove/ to example.com

thing is, the index is located in the "remove" directory.

I've tried: 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

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 .

And then restart your server.

Or if not use this in .htaccess

DirectoryIndex index.html

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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