1

I have an apache server running in Linux and I'm wondering how I would go about redirecting urls? I want to do this via apache not by adding a header or redirect into the individual files. The goal is to get around having to deal with .aspx

Example1:

VISITING: wwww.myserver.com/file1.aspx
Will take you to: www/myserver.com/file2.php

Example2:

VISITING: www.myserver.com/file1.aspx?command1=set&command2=set
Will take you to: www.myserver.com/file2.php?command1=set&command2=set
Matt Stokes
  • 4,618
  • 9
  • 33
  • 56
  • I'm working through the following example: http://stackoverflow.com/questions/1295148/apache-redirect – Matt Stokes Aug 28 '12 at 19:56
  • ok but that link is using a `.htaccess` and enabling the `mod_rewrite`. Why are you using apache, on linux and have `.aspx` files? –  Aug 28 '12 at 20:08
  • I don't want to use .aspx. I want to redirect a request away from a .aspx page to a php page while keeping all the $_GET data – Matt Stokes Aug 28 '12 at 20:10
  • Have you already enabled the mod_rewrite Apache module? –  Aug 28 '12 at 20:11
  • Yes, and I believe I've gotten it working following the example outlined in : stackoverflow.com/questions/1295148/apache-redirect just needed to used RewriteRule ^file1.aspx file2.php [L,R=301] – Matt Stokes Aug 28 '12 at 20:16
  • if it is solved please post a answer ;) –  Aug 28 '12 at 20:26

1 Answers1

2

Without using mod_rewrite, you can simply use mod_alias, in your vhost/server config or in an htaccess file:

Redirect 301 /file1.aspx /file2.php
Jon Lin
  • 142,182
  • 29
  • 220
  • 220
  • Excellent way to do it! I have converted some of my websites from ASP.NET to PHP. This has saved me a LOT of time! Thank you! – kodybrown Jan 10 '13 at 17:31