如何隐藏索引?q =在php中?

See, I am developing my application on core php and with that I am working on an application in which the index.php file loads all the template files according to the query. e.g; if user want to go to profile page, the url is, sitename/index.php?q=profile, and for settings page the url is, sitename/index.php?q=settings.

I want to make it clean url, like for profile the url should be like, sitename/profile and sitename/settings.

I have searched alot on this topic but has not been successful. Any help would be appreciated. Thankyou.

you could use following code in your .htaccess file to have clean url

RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)$ index.php?q=$1
RewriteRule ^([a-zA-Z0-9]+)/$ index.php?page=$1

Please learn how to define rules in .htacces You can start up from here and also check an example at stackoverflow answer

Either shift to MVC architecture and define your routes there accordingly, or use asynchronous requests through JavaScript and fetch and render stuff on the front end itself. Given your situation, both options would take about the same time to implement. Consider other factors of your project and then chose wisely.