dongshukou0240 2014-02-19 21:13
浏览 57
已采纳

使用.htaccess自定义URL或隐藏查询字符串

I am new one, I learn .htaccess. I want to customize my URL from index.php?page=mobile to index/page/mobile

I used this code but it doesn't work:

RewriteEngine on
RewriteRule    ^index/([0-9]+)/?$    index.php?page=$1    [NC,L]    # Handle product requests

and

RewriteEngine on
RewriteRule ^index/([^/.]+)/?$ index.php?page=$1 [L]
  • 写回答

3条回答 默认 最新

  • douqiju2520 2014-02-19 21:19
    关注

    This rule should work:

    RewriteEngine on
    RewriteBase /cashearn/
    
    RewriteCond %{THE_REQUEST} /index\.php\?page=([^\s&]+) [NC]
    RewriteRule ^ index/page/%1? [R=302,L]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^index/page/([^/]+)/?$ index.php?page=$1 [L,QSA,NC]
    

    This will let you have URL as http://domain.com/index/page/mobile on your page.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 在使用pyecharts时出现问题
  • ¥15 深度学习残差模块模型
  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计