drb56625 2017-08-12 16:03
浏览 43
已采纳

.htaccess RewriteRule无法在我的localhost上运行

I am fairly new to php and RewriteRules, I tried to make localhost/webapp/sign_up.php point to localhost/webapp/sign_up. This is my .htaccess code:

RewriteEngine On
RewriteRule ^sign_up/?$ sign_up.php

but when I go to localhost/webapp/sign_up it says:

Not Found

The requested URL /webapp/sign_up was not found on this server.

I am using apache2 (Ubuntu) by the way and I am sure rewrite_mod is enabled.

In case it helps, my .htaccess is under var/www/html/webapp

  • 写回答

3条回答 默认 最新

  • duanliang789262 2017-08-12 16:19
    关注

    Try this and let me know

    RewriteEngine On
    RewriteBase /webapp/
    RewriteRule ^([a-z_]+)/?$ $1.php [NC,L]
    

    And make sure the mod_rewrite module is enabled by running these commands

    sudo a2enmod rewrite
    sudo service apache2 restart
    

    And if all else fails please try setting a virualhost and after read this article about setting up mod_rewrite

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

报告相同问题?

悬赏问题

  • ¥15 TMC2209串口模式下读取不到寄存器的值串口助手蓝色字体是发过去的消息,绿色字体是收到的消息,第二行发送读取寄存器的指令但是没有读取到寄存器的值串口助手如下图:接线如下图,如何解决?
  • ¥30 itest不允许查看成绩怎么办
  • ¥15 高通安卓11提取完整线刷包软件,或者优博讯dt50顺丰刷机包
  • ¥20 C,有个译码器,换了信道就跑不出原来数据
  • ¥15 MIMIC数据库安装问题
  • ¥60 基于JTag协议开发Fpga下载器上位机,哪位大🐂有偿指导?
  • ¥20 全书网Java爬取数据
  • ¥15 怎么获取红包封面的原始链接,并且获取红包封面序列号
  • ¥100 微信小程序跑脚本授权的问题
  • ¥100 房产抖音小程序苹果搜不到安卓可以付费悬赏