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 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器