htaccess mod_rewrite part of url to GET variable

后端 未结 2 720
再見小時候
再見小時候 2020-12-18 12:24

I have some URLs like these:

  • http://plutov.by/post/cubique_zf_jquery
  • http://plutov.by/post/mysql_useful_queries
2条回答
  •  南方客
    南方客 (楼主)
    2020-12-18 13:08

    To make the new rewrite rule work with "one entry point rewriting", have your rewriteRules like this:

    The QSA flag is mandatory as you are adding a new query string.

    RewriteEngine On
    
    RewriteRule ^(post)/([\w\d\-]+)/?$ $1/main?title=$2 [QSA]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule . index.php [L]
    
    • Flag QSA Apache Docs.
    • !-l checks that the requested URI is not a symbolic ink.

提交回复
热议问题