doris20141022 2011-09-18 06:04
浏览 38
已采纳

.htaccess中的自动URL重写

At first I used IIS server for PHP, so I'm new to Apache (Windows platform). I am in some puzzle related with URL rewrite. As in my .htaccess file I use the below code for URL Rewrite.

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.aspx$ $1.php [nc]

Now If I browse a .php page with .aspx extension, it works well. eg If I browse

www.example.com/guwahati.php => www.example.com/guwahati.aspx (both URL works.)

But I want it automatically. Like if I type www.example.com/guwahati.php, it will automatically convert to www.example.com/guwahati.aspx, is it possible ? also URL rewritting is not working on my localhost. may anyone help me please.

  • 写回答

1条回答 默认 最新

  • dtntjwkl83750 2011-09-18 06:08
    关注

    But I want it automatically. Like if I type www.example.com/guwahati.php, it will automatically cconvert to www.example.com/guwahati.aspx, is it possible ?

    It is possible, but by using redirect headers, not URL rewrites. Actually you could do an URL rewrite that redirects to a single file that replaces the target extension with aspx and then redirects to it. You may need to enable mod_rewrite in order for it to work.

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

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?