简体   繁体   中英

remove folder from url with htaccess

So I have a folder named pages which includes the pages for my site, when opening one of these files the url reads -

zebrafishweb/pages/contact

I would like it to just read

zebrafishweb/contact

I already have this htaccess file to remove any.php.html extensions which i would also like to carry on using. I don't have a clue how to write these htaccess files just copied it from the web and tailored it to me!

 RewriteEngine on

 RewriteRule ^(themes|order-now|submissions|faq|contact)$ $1.php [NC,L]
 RewriteRule ^(home|faq)$ $1.html [NC,L]

With your shown samples please try following .htaccess Rules file. Make sure to clear your browser cache before testing your URLs.

RewriteEngine on
RewriteBase /zebrafish/pages/

RewriteRule ^zebrafish/pages/contact/?$ /contact? [R=301,NC,L]

RewriteRule ^(themes|order-now|submissions|faq|contact)$ zebrafish/pages/$1.php [NC,L]
RewriteRule ^(home|faq)$ $1.html [NC,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