dsaaqdz6223 2011-02-08 01:47
浏览 5
已采纳

我无法弄清楚为什么我的网址重写不起作用

Hey guys. I'm new to url rewrites but I can't seem to figure out why this is not working

I have the link: http://thoughtsmash.com/profile.php?name=1

That I want to rewrite to: http://thoughtsmash.com/profilename/1

and I have this in my .htaccess file:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,NC,L]
RewriteRule ^/profilename/([0-9_]+)$ /profile.php?name=$1 [NC]

But it does nothing! The removal of the "www." works fine but the rest doesn't. Any ideas as to why? Thanks

  • 写回答

1条回答 默认 最新

  • dqde43215 2011-02-08 01:54
    关注

    Try this:

    Options +FollowSymlinks
    RewriteEngine on
    
    RewriteBase /
    
    RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,NC,L]
    
    RewriteRule ^profilename/([0-9_]+)$ /profile.php?name=$1 [NC]
    

    Note that I added RewriteBase and removed leading /

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程