Page 1 of 2 1 2 LastLast
Results 1 to 15 of 17

301 /index.php > .com

This is a discussion on 301 /index.php > .com within the General Discussion forums, part of the vBSEO SEO Plugin category; Hey, I have searched around and can't for the life of me find away to 301 www.mydomain.com/index.php to www.mydomain.com I'm ...

  1. #1
    Junior Member
    Real Name
    Dane
    Join Date
    Jan 2008
    Posts
    12
    Liked
    0 times

    301 /index.php > .com

    Hey,

    I have searched around and can't for the life of me find away to 301 www.mydomain.com/index.php to www.mydomain.com

    I'm guessing it is very easy and I'm just looking in the wrong places or it's a little harder then I though.

    Anyone have any idea?

    This is from my VB advanced front page by the way. Thanks to VBSEO my forum does this already.

  2. #2
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,741
    Liked
    168 times
    Hello,

    you can create .htaccess in domain root:
    Code:
    RewriteCond %{THE_REQUEST} /index\.php
    RewriteRule ^index\.php$ http://www.domain.com [L,R=301]

  3. #3
    Junior Member
    Real Name
    Dane
    Join Date
    Jan 2008
    Posts
    12
    Liked
    0 times
    Awesome, thanks

    Worked perfectly.

    I just found another one.

    www.mydomain.com/index.php?pageid=home

    The current rewrite from above removes the index.php but leaves behind the ?pageid=home so it looks like http://www.mydomain.com/?pageid=home

    Anyway to make that just www.mydomain.com

    Thanks for the help.

  4. #4
    Member Viper007Bond's Avatar
    Real Name
    Viper007Bond
    Join Date
    Jan 2008
    Location
    Portland, Oregon, USA
    Posts
    65
    Liked
    0 times
    Php?
    FinalGear.com Forums -- my site/forums dedicated to Top Gear and Fifth Gear, two UK TV shows

  5. #5
    Junior Member
    Real Name
    Dane
    Join Date
    Jan 2008
    Posts
    12
    Liked
    0 times
    I'm assuming you mean is it running php?

    If so yes....

  6. #6
    Member Viper007Bond's Avatar
    Real Name
    Viper007Bond
    Join Date
    Jan 2008
    Location
    Portland, Oregon, USA
    Posts
    65
    Liked
    0 times
    No, I mean do it via PHP:

    PHP Code:
    <?php if ( 'home' == $_GET['pageid'] ) { header'Location: http://www.mydomain.com/' ); } ?>
    Stick that at the top of your index.php file.
    FinalGear.com Forums -- my site/forums dedicated to Top Gear and Fifth Gear, two UK TV shows

  7. #7
    Junior Member
    Real Name
    Dane
    Join Date
    Jan 2008
    Posts
    12
    Liked
    0 times
    I get this on the main page?

    Code:
    Parse error: syntax error, unexpected '<' in /home/surfaus/public_html/index.php on line 2
    Line 2 is where I placed that code.

  8. #8
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,741
    Liked
    168 times
    Change rewrite rule to:
    Code:
    RewriteCond %{THE_REQUEST} /index\.php
    RewriteCond %{QUERY_STRING} ^$
    RewriteRule ^index\.php$ http://www.domain.com [L,R=301]

  9. #9
    Member Viper007Bond's Avatar
    Real Name
    Viper007Bond
    Join Date
    Jan 2008
    Location
    Portland, Oregon, USA
    Posts
    65
    Liked
    0 times
    Or even better!
    FinalGear.com Forums -- my site/forums dedicated to Top Gear and Fifth Gear, two UK TV shows

  10. #10
    Junior Member
    Real Name
    Dane
    Join Date
    Jan 2008
    Posts
    12
    Liked
    0 times
    Quote Originally Posted by Oleg Ignatiuk View Post
    Change rewrite rule to:
    Code:
    RewriteCond %{THE_REQUEST} /index\.php
    RewriteCond %{QUERY_STRING} ^$
    RewriteRule ^index\.php$ http://www.domain.com [L,R=301]
    Thanks but all that did was make it go back to

    http://www.mydomain.com/index.php?pageid=home

    I would like that to rewrite it to www.mydomain.com.

    I will also be adding other pages to vbadvanced that will have the same URL structure so I would like to be able to rewrite them too if possible.

    Any ideas?

    Thanks for the help so far.

  11. #11
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,741
    Liked
    168 times
    Change the second line to:
    RewriteCond %{QUERY_STRING} ^(pageid=home)?$

  12. #12
    Junior Member
    Real Name
    Dane
    Join Date
    Jan 2008
    Posts
    12
    Liked
    0 times
    It's still leaving behind the the /?pageid=home on the end. That still leads to a copy of my front page.

    This is what I have at the moment.

    Code:
    Options +FollowSymlinks
    RewriteEngine on
    rewritecond %{http_host} ^surfaus.com.au [nc]
    rewriterule ^(.*)$ http://www.surfaus.com.au/$1 [r=301,nc]
    
    RewriteCond %{THE_REQUEST} /index\.php
    RewriteCond %{QUERY_STRING} ^(pageid=home)?$
    RewriteRule ^index\.php$ http://www.surfaus.com.au [L,R=301]
    index.php gets changed too /

    index.php?pageid=home gets changed too /?pageid=home

    I would be happy at the moment if I could even just make /?pageid=home 404 but it just loads the front page and duplicates the content once again.

    Thanks for the help,

    Anymore ideas would be great. I have no idea how to do this, so your my last hope.

  13. #13
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,741
    Liked
    168 times
    Mm.. please try this as the last line:
    Code:
    RewriteRule ^index\.php$ http://www.surfaus.com.au/? [L,R=301]

  14. #14
    Junior Member
    Real Name
    Dane
    Join Date
    Jan 2008
    Posts
    12
    Liked
    0 times
    YEH!!

    One step closer.

    /index.php?pageid=home now goes to / which is awesome.

    Everything is great now except that /?pageid=home which has already been indexed and still shows the front page.

    Is there anyway to make this rewrite to / or even just 404?

  15. #15
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,741
    Liked
    168 times
    Yay!
    Everything is great now except that /?pageid=home which has already been indexed and still shows the front page.
    You should add one more rewrite rule then:
    Code:
    RewriteCond %{QUERY_STRING} ^pageid=home$
    RewriteRule ^$ http://www.surfaus.com.au/? [L,R=301]

Page 1 of 2 1 2 LastLast

Similar Threads

  1. cannot get index.php to go to /
    By nysports365 in forum Custom Rewrite Rules
    Replies: 8
    Last Post: 06-21-2007, 09:03 AM
  2. index.html to index.php
    By Doug Nelson in forum URL Rewrite Settings
    Replies: 2
    Last Post: 05-18-2007, 08:13 PM
  3. Rewrite index.php and index.php? to a folder.
    By FleaBag in forum General Discussion
    Replies: 14
    Last Post: 03-24-2007, 08:06 PM
  4. Rewriting index.php to index.html
    By Lian in forum General Discussion
    Replies: 2
    Last Post: 07-12-2006, 02:36 PM

Posting Permissions

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