dreamice2013 2015-03-28 02:05
浏览 63
已采纳

.Htaccess RewriteRule将所有页面重定向到404页面未找到错误

I have a long url in the following format

      example.com/user.php?uname=foo&pass=bar

the problem with this url is that it is not at all memorable,

So I want to change it into a search engine friendly url

  example.com/foo/bar

I have tried this rule in my htaccess that is on the web root

 RewriteRule ^([a-zA-Z0-9]+)([a-zA-Z0-9]+)/?$mysite.com/user.php?uname=$1&pass=$2

but the problem is that its not working ,It redirects every page requests to 404 not found.

Any ideas?

  • 写回答

1条回答 默认 最新

  • dsiy62758 2015-03-28 04:43
    关注

    Try this:

    RewriteEngine on
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/?$ /user.php?uname=$1&pass=$2 [QSA,L]
    

    The conditions make sure you don't rewrite any existing file/directories on the server.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测