Make htaccess rule apply only to the current folder

前端 未结 1 1046
陌清茗
陌清茗 2020-12-11 11:03

I saw this example of how to change index.php to the url name

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
Rewri         


        
相关标签:
1条回答
  • 2020-12-11 11:13

    Have your .htaccess as this:

    RewriteEngine On
    
    # skip all rules below this for files and directories
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    
    RewriteRule ^([\w-.]+)/?$ index.php?id=$1 [L,QSA]
    
    RewriteCond %{DOCUMENT_ROOT}/site/map/$2 -f
    RewriteRule ^([\w-]+)/(.+)/?$ $2?id=$1&goto=$2 [L,QSA]
    
    RewriteCond %{DOCUMENT_ROOT}/site/map/$2/index.php -f
    RewriteRule ^([\w-.]+)/([a-z0-9]+)/?$ $2/index.php?id=$1&goto=$2 [NC,L,QSA]
    
    RewriteRule ^([\w-.]+)/([a-z0-9]+)/?$ index.php?id=$1&goto=$2 [NC,L,QSA]
    
    0 讨论(0)
提交回复
热议问题