Routing php query using .htaccess

前端 未结 1 1706
轻奢々
轻奢々 2020-12-22 01:37

I am trying to find a better solution to solve the issue. I am not using any framework like silex, Yii, etc. Thus I do not have the general routing handling mechanism provid

相关标签:
1条回答
  • 2020-12-22 02:24

    Have your .htaccess like this:

    RewriteEngine On
    RewriteBase /name/
    
    RewriteCond %{DOCUMENT_ROOT}/name/$1.php -f
    RewriteRule ^([^/]+)/([^/]+)/?$ $.php1?action=$2 [L,NC,QSA]
    
    RewriteCond %{DOCUMENT_ROOT}/name/$1.php -f    
    RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ $1.php?action=$2&id=$3 [L,NC,QSA]
    
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME}\.php -f 
    RewriteRule ^(.*)$ $1.php [L]
    
    0 讨论(0)
提交回复
热议问题