Simple Mod Rewrite

前端 未结 3 1815
盖世英雄少女心
盖世英雄少女心 2020-12-11 06:14

I\'m trying to create a mod rewrite to simply turn these links:

/index.php?page=home
/?page=home

into

/home
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-11 06:58

    If I understand, you want your end users to enter example.com/home and have that rewritten in to /index.php?home?

    RewriteEngine On
    # /home or / get redirected...
    RewriteRule ^(home)?$ /index.php?page=home [L,QSA]
    

    To debug, you can enable the RewriteLog. However, as suggested in the comments it should be used for debugging only. It is best to disable it or set the level very low in production.

    RewriteLog "/path/to/logs/rewrite.log"
    # Increase the log level (default 0, >4 gets pretty verbose) 
    RewriteLogLevel 3 
    

提交回复
热议问题