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 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突