Dubli Join Us

Search About New Technology and Bug

Loading...

Wednesday, November 2, 2011

remove index.php from wordpress on win2003 shared hosting

No need to install any ISAPI filter to remove the index.php from WordPress permalinks.No need of .htaccess file..Use these simple steps to WordPress Permalinks in IIS 6.0 using Custom 404 Redirect for Windows Shared hosting/manas hosting or any windows shared hosting.When you run wordpress on IIS server your permalinks have to include the prefix /index.php/ which looks ugly and is totally unnecessary.If you have these requirements as follow: 

a.IIS for Windows Shared Hosting
b.WordPress Site
c.Access to change your 404 error page with your web hosting.

This can be remove by following simple steps.

1Once installed wordpress blog on your site you’ll want to log into the admin section and select options and then select permalinks. Set your permalinks as you wish.

2. Then You’ll create a new text file and name it "404-error.php". In this text file you’re going to include the text:


<?php
// This is the default file for the site. Usually index.php
$default = 'index.php';

// The name of this file.
// Set this value for the URL in Custom Error Properties of your website in IIS.
// Goto: IIS Manager > Websites > [Site Name] > Properties > Custom Errors >
// 404 & 404;2 & 404;3 > URL (Requires a '/' prefix in IIS).
$thisfile = '404-error.php';

$_SERVER['ORIG_PATH_TRANSLATED'] = str_replace($thisfile, $default, $_SERVER['ORIG_PATH_TRANSLATED']);
$_SERVER['SCRIPT_FILENAME'] = str_replace($thisfile, $default, $_SERVER['SCRIPT_FILENAME']);
$_SERVER['ORIG_PATH_INFO'] = str_replace($thisfile, $default, $_SERVER['ORIG_PATH_INFO']);
$_SERVER['SCRIPT_NAME'] = str_replace($thisfile, $default, $_SERVER['SCRIPT_NAME']);
$_SERVER['PHP_SELF'] = str_replace($thisfile, $default, $_SERVER['PHP_SELF']);
$_SERVER['PATH_INFO'] = false;

$qs =& $_SERVER['QUERY_STRING'];
$ru =& $_SERVER['REQUEST_URI'];
$pos = strrpos($qs, '://');
$pos = strpos($qs, '/', $pos + 4);
$_SERVER['URL'] = $ru = substr($qs, $pos);
$qs = trim(stristr($ru, '?'), '?');

// Required for WordPress 2.8+
$_SERVER['HTTP_X_ORIGINAL_URL'] = $ru;

// Fix GET vars
foreach ( $_GET as $var => $val ) {
  if ( substr($var, 0, 3) == '404') {
    if ( strstr($var, '?') ) {
      $newvar = substr($var, strpos($var, '?') + 1);
      $_GET[$newvar] = $val;
    }
    unset($_GET[$var]);
  }
  break;
}
include($default);
?>
then Upload 404-error.php into the root directory of your blog.

3.Set a custom 404 redirect to “/404-error.php”. It is important that the type of redirect is set to URL.
You can change this directly from within IIS by selecting Properties -> Custom Errors. Select 404. Edit. Set Message Type to URL (you have the option of File, URL or Default). Set it to /404-error.php.

4. That's It done.Check your blog.It will working Fine.

Google Search Keywords:Remove index.php wordpress, remove index.php on shared hosting,php url host,godaddy wordpress install,installing wordpress godaddy,wordpress install godaddy,wordpress custom urls,installing wordpress on iis,godaddy iis,wordpress custom url,url rewrite in wordpress
htaccess url,,wordpress rewrite url,htaccess rewriting,wordpress isapi rewrite,change wordpress url,windows iis,wordpress url rewrite,wordpress url rewriting,iis rewrite rule,isapi rewrite wordpress

18 comments:

  1. I am running Manashosting services, it show index.php in the url http://assuredreturnproperties.com/index.php/gurgaon/

    I dint got 3rd Step, where i can IIS

    ReplyDelete
  2. @GrowingBricks

    go to the webspace tab in control panel, then click on WebSite Configuration. it will display some tab in right side, click on Error Documents. then click on 404 in list it will display the following windows.

    ReplyDelete
  3. How's your webmaster tools with this solution? How's the 404 error pages? Do they work?

    ReplyDelete
  4. @Rod Ferris

    yes of-course this work pls check this site

    www.dotnetspider.in

    a wordpress site on windows shared hosting.

    ReplyDelete
  5. Thanks a lot Brother......
    I solve it
    http://assuredreturnproperties.com/gurgaon/

    God Bless you

    ReplyDelete
  6. Is there a way to do this with Mac? I don't use IIS. Thanks.

    ReplyDelete
  7. Thanks this worked but now the home page returns error 404 instead of the selected page in settings/reading

    ReplyDelete
  8. Hey, I worked this out, but I am getting a message "the data is invalid" So, I know the custom 404 error is getting redirected, but something else is not right.

    ReplyDelete
  9. Just wondering if this approach has any implications on SEO ?

    ReplyDelete
  10. Great work www.mintywebs.com thanks!

    ReplyDelete
  11. Worked like a charm!

    ReplyDelete
  12. Yes! Finally ѕomeone writes about seoo hаrvard.



    Also νisit my websitе ... seo's

    ReplyDelete
  13. There's a flaw with this - your wegbserver will now response to every duff request (domain.com/reallyRubbishUrl/) with a 200, not 404, status code.
    Does anyone have a cure of that please?

    ReplyDelete
  14. This works perfectly well for all inside pages. Only the home page is not showing any contents. Blank page appears without any errors, when I click the home button from any page. My wordpress blog site is blogs.halloweencostumesale.com.
    blogs.halloweencostumesale.com/index.php shows the home page correctly.

    http://blogs.halloweencostumesale.com/memorial-day-costumes/ shows correctly. Only the home page is a problem. When I check with httpWatch, I see that the home page is returning a 404 error.

    ReplyDelete
    Replies
    1. Yes. Because without the third step even my inside pages were not working. The inside pages are working fine without the index.php required in the url, but the home page does not work without the index.php added. Hence,
      blogs.halloweencostumesale.com is not working and only
      blogs.halloweencostumesale.com/index.php is working.
      However,
      http://blogs.halloweencostumesale.com/about-us/ and all other inside urls work perfectly well.

      Delete
  15. I wasted more than 6-8 hours trying to find a solution and yours is the only solution which is easiest to implement and has worked well for me except this home page issue. Can you please help resolve this issue for me. I have lost patience to do any further research or try any other solutions.

    Please help at the earliest.

    ReplyDelete