url rewriting index.php

前端 未结 2 1021
挽巷
挽巷 2021-01-07 12:53

i have urls like

http://mysite.com/index.php?p=resources
http://mysite.com/index.php?p=resources&s=view&id=938

but i want urls like

2条回答
  •  余生分开走
    2021-01-07 13:26

    Create a .htaccess file. Not somefilename.htaccess, it is simply named .htaccess.
    Note: Your index.php and .htaccess file should be in the same directory.

    Now try this on your .htaccess file


    RewriteEngine on
    RewriteRule ^([A-Za-z0-9\-]+)$ index.php?p=resources
    RewriteRule ^([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/([0-9]+)$ index.php?p=resources&s=view&id=938

    see more about url rewrite here

提交回复
热议问题