How can I remove this directory/folder from url with htaccess rewrite?

前端 未结 2 2028
孤城傲影
孤城傲影 2020-12-11 18:43

My aim is:

domain.com/folder

rewrite ->

domain.com

this shall concern ALL links inside that site. I mean

相关标签:
2条回答
  • 2020-12-11 19:02

    You can use this code:

    Goes in DOCUMENT_ROOT/wedgiecommunity/.htaccess:

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

    Goes in DOCUMENT_ROOT/.htaccess:

    RewriteEngine On
    
    RewriteRule !^/?wedgiecommunity wedgiecommunity%{REQUEST_URI} [L,NC]
    
    0 讨论(0)
  • 2020-12-11 19:19

    You can use this rule to "remove" the folder from the URL when it is accessed directly via the browser:

    RewriteCond %{THE_REQUEST} \ /wedgiecommunity/
    RewriteRule ^wedgiecommunity/(.*)$ /$1 [L,R=301]
    

    Then your other rule will handle the rest.

    0 讨论(0)
提交回复
热议问题