-2

I'd like to redirect a URL such as www.example.com/something to another site. I created a PHP script to do this, but in order for it to work I have to type in www.example.com/something.php.

I want to avoid users having to type in the .php or .html when accessing the redirected page. Would I have to create a directory on my webserver? And if so, what should I place in it?

I'm using a GoDaddy hosted Windows server (PHP Version 5, ASP.Net 2.0/3.0/3.5)

Stephan Muller
  • 27,018
  • 16
  • 85
  • 126

3 Answers3

0

You don't even need PHP for this. Simply create a rewrite rule to do the redirection. How you do this depends on your web server, which you didn't specify, so I'll leave the writing of the actual rule up to you.

Brad
  • 159,648
  • 54
  • 349
  • 530
0

Use this meta tag in the head section of your HTML file:

<meta http-equiv="refresh" content="0; url=http://www.othersite.com">

See this StackOverflow question: Redirect from an HTML page

Alternatively you can use JavaScript to do this by placing the following in the head section of your HTML file:

<script type="text/javascript">
    window.location.href = 'http://www.othersite.com';
</script>

Note: See this answer. I partially used it to improve this post.

Community
  • 1
  • 1
Sumner Evans
  • 8,951
  • 5
  • 30
  • 47
0

you will need to rewrite you url ,create a new file in root directory paste the following code in it

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

and save it as .htaccess for more detail you can check this link http://alexcican.com/post/how-to-remove-php-html-htm-extensions-with-htaccess/

to remove .html from url paste this in your .htaccess file

RewriteRule ^([^\.]+)$ $1.html [NC,L]
Dexture
  • 976
  • 1
  • 11
  • 29