Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2006
    Posts
    4,832
    Tokens
    0

    Latest Awards:

    Default Broken links - HELP!

    Hi guys,

    I have created a site in PHP that allows me to have URLs like http://site.com/this-is-a-page

    I've done it with custom 404 pages... basically it gets whats at the end of the URL, checks for it in the database and if it's there it'll display the content for that specific url. I find it looks better than view.php?id=1 and is more informative if somebody sees the link.

    Problem is Google hadn't indexed these links! I was confused why, so I did some looking around and created a sitemap - all of the custom URLs could not be added because they were 'broken links' - how do I get around this? Wordpress does it and other sites, what do I need to do?

    Thanks.

  2. #2
    Join Date
    Apr 2008
    Location
    Derby
    Posts
    4,668
    Tokens
    262

    Latest Awards:

    Default

    Look into .htaccess and maybe mod_rewrite but I'm unsure sorry :L
    Back for a while

  3. #3
    Join Date
    Jun 2006
    Posts
    4,832
    Tokens
    0

    Latest Awards:

    Default

    OK got some info on that.

    Code:
    RewriteEngine On
    RewriteRule ^(.*).html view.php?url=$1
    That will direct page-name.html to view.php?url=page-name (which then executes a query to get the info and displays) - I don't want .html on the end, so I change it to this...

    Code:
    RewriteEngine On
    RewriteRule ^(.*) view.php?url=$1
    That now gives nothing - every page on the website is BLANK. So it would be site.com/page-name but it's blank... However if I do this...


    Code:
    RewriteEngine On
    RewriteRule ^(.*)/ view.php?url=$1
    site.com/page-name comes up with 404, HOWEVER site.com/page-name/ comes up with the thing I want... but I don't want the trailing slash as when it's not added it won't work.

    HELP!

  4. #4
    Join Date
    Apr 2010
    Location
    Newcastle
    Posts
    655
    Tokens
    50

    Default

    Google won't index pages with a 404 response.

    Code:
    RewriteEngine On
    RewriteRule ^(.*) view.php?url=$1
    The reason that shows a blank page is because it creates an infinite loop - the final URL matches the target URL and so on. Try changing to:

    Code:
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*) view.php?url=$1
    This checks and only redirects if the file doesn't exist (avoiding an infinite redirect).

  5. #5
    Join Date
    Jun 2006
    Posts
    4,832
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Apolva View Post
    Google won't index pages with a 404 response.

    Code:
    RewriteEngine On
    RewriteRule ^(.*) view.php?url=$1
    The reason that shows a blank page is because it creates an infinite loop - the final URL matches the target URL and so on. Try changing to:

    Code:
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*) view.php?url=$1
    This checks and only redirects if the file doesn't exist (avoiding an infinite redirect).
    I love you again. That has worked. I was working on a redirect when page-name is there to page-name/ 'cos it worked with a slash, but I don't want the slash... and what you've done works without it. You are awesome.

Posting Permissions

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