duanjizhan9353 2013-09-17 02:55
浏览 65
已采纳

htaccess重写没有.php扩展名到文件的URL

I got a website that using osCommerce which all the page can be access directly with http://www.example.com/pagename.php, but now I would like to tweak the htaccess file so that it can supports http://www.example.com/username and then redirecting to http://www.example.com/account.php?id=username, while other pages still can be access using the same old way.

It means that if the htaccess detect that the URL didn't have any extension, then it will be redirecting to http://www.example.com/account.php?id=username.

Thank you!

  • 写回答

2条回答 默认 最新

  • doukuilian8365 2013-09-17 06:57
    关注

    You just need one rule:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/.]+)/?$ /account.php?id=$1 [L,QSA]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 MS中不知道高分子的构型怎么构建模型
  • ¥60 QQOP数据,什么是op数据号,怎么提取op数据!能不能大量提取(语言-c语言)
  • ¥15 matlab代码 关于微分方程和嵌套的分段函数。
  • ¥15 把VMware项目复制到另一台电脑
  • ¥15 onlyoffice编辑完后立即下载,下载的不是最新编辑的文档
  • ¥15 求caverdock使用教程
  • ¥15 Coze智能助手搭建过程中的问题请教
  • ¥15 12864只亮屏 不显示汉字
  • ¥20 三极管1000倍放大电路
  • ¥15 vscode报错如何解决