Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jun 2008
    Location
    Jupiter
    Posts
    49
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Redirecting index.php to index.html

    I tried it using .htaccess, but it didnt work. here is the code below.

    PHP Code:

    RewriteCond 
    %{THE_REQUEST} ^GET .*/website.(php|htmlHTTP
    RewriteRule 
    ^(.*)website.(php|html)$ /$[R=301,L
    Do anyone have any suggestions for doing this in php? The thing im confused about regarding redirecting a .php file to an .html file, is do i only need to write an .php file, and the contents in it will redirect to index.html, or should both files contain identical information? Thanks.

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I think we need to know why you want to redirect to index.html from index.php. There may be better or other ways to do what you want.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New Coder
    Join Date
    Jun 2008
    Location
    Jupiter
    Posts
    49
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by _Aerospace_Eng_ View Post
    I think we need to know why you want to redirect to index.html from index.php. There may be better or other ways to do what you want.

    Sure, i dont like seeing the .php extensions. I want all of my pages to just be in either .html or .com.

  • #4
    New Coder
    Join Date
    Aug 2007
    Posts
    69
    Thanks
    11
    Thanked 2 Times in 2 Posts
    .htaccess should work easily.

    Code:
    Redirect 301 /index.php http://www.yoursite.com/index.html

  • Users who have thanked michaelespinosa for this post:

    tokio (07-31-2009)

  • #5
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Quote Originally Posted by tokio View Post
    Sure, i dont like seeing the .php extensions. I want all of my pages to just be in either .html or .com.
    But you still want to use php in your files? If that is the case then you need to make your server serve up html files as php files.

    Read this

    http://www.desilva.biz/php/phpinhtml.html

    That should work. Now you can use .html but you can still use .php in them. Can I ask why you want this though? I don't see the problem with using .php
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    tokio (07-31-2009)

  • #6
    New Coder
    Join Date
    Jun 2008
    Location
    Jupiter
    Posts
    49
    Thanks
    8
    Thanked 0 Times in 0 Posts
    @ michael: Thanks, but i was looking for more of an automated approach.

    @eng: Thanks for that. Good question by the way, its more for marketing purposes, as i think most people visiting a site and dont could would remember a .html url as opposed to a .php.

  • #7
    New Coder
    Join Date
    Jul 2009
    Location
    Eastern United States
    Posts
    14
    Thanks
    0
    Thanked 4 Times in 4 Posts
    That makes complete sense. From a security point of view it is useful too. The less they know about how the site runs the better.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •