dongxie45083 2010-04-29 23:33
浏览 90
已采纳

php url路由问题

http://mysite.com/songs/company-name/song-name

i want to redirect it to

http://mysite.com/songs/index.php?name=company-name&song=song-name

i read some articles about that mod_rewrite but actually i couldnt understand exactyly, i appreciate if you can help me.

thanks

EDIT: mod rewrite is enabled

  • 写回答

3条回答 默认 最新

  • dougou1127 2010-04-29 23:47
    关注

    Check if your apache installation has mod_rewrite enabled.

    In its simplest form, the rule to accomplish what you want to do would be:

    In your .htaccess

    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^mysite.com$
    RewriteRule ^/?$ http://mysite.com [R=301,L]
    
    RewriteRule songs/(.*)/(.*)$ songs/index.php?name=$1&song=$2
    

    But give it a read to the apache documentation http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html as well as verify your configuration, and here you'd find some useful stuff as well http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/#redirects

    Hope that helps.

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

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法