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.

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

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面