douhuan1497 2015-10-31 07:40
浏览 54

使用wamp和php实现URL重写

I can't implement URL rewriting.

What I've done so far:

1. Enabled rewrite_module in apache.

2. Added a .htaccess file to my website (test) in the directory:

127.0.0.1/test/

which contains the following:

RewriteEngine on
RewriteRule ^/news/([0-9]+)\.html /news.php?news_id=$1

3. I have a news.php file which contains

echo "hello world";

Now, whenever I go to URL: http://127.0.0.1/news/1, I get a

'Page not found'

  • 写回答

2条回答 默认 最新

  • dqdfpmmi022763 2015-10-31 08:18
    关注

    I was successful in the following.

    Files:

    document_root/
    |- .htaccess
    |- news.php
    

    .htaccess:

    RewriteEngine on
    RewriteRule news/([0-9]+)\.html news\.php?news_id=$1
    

    http://127.0.0.1/news/1.html
    -> hello world

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大