My pages don't end in any extension, is this ok?

Discussion in 'Site & Server Administration' started by Your Lover For Ever, Sep 29, 2009.

  1. #1
    Hi,

    I have a wallpaper site, which have all pages do not end in any extensions. For example, my pages look like this:

    www.example.com/wallpaper/65355

    instead of

    www.example.com/someWallpaper.html

    One of the biggest troubles I faced in case of this issue, is that my pages always get rejected on "Digg site" submission :( , And many other problems in addition.

    Does it possible to fix this?
    thank you
     
    Your Lover For Ever, Sep 29, 2009 IP
  2. Azkaban

    Azkaban Peon

    Messages:
    537
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    One option would be to append the following line in your ".htacess" file..
    Be sure to add this line after all rewrite rules automatically specified by your script..

    RewriteRule ^wallpaper/(.*)\.html$ wallpaper/$1 [L]
    Code (markup):
    P.S. --> I'm not so good at mod_rewrite. May be I'm wrong about the code.
     
    Last edited: Sep 29, 2009
    Azkaban, Sep 29, 2009 IP
  3. MikeDVB

    MikeDVB Peon

    Messages:
    113
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Looks close enough to get the OP started if it's not correct.
     
    MikeDVB, Sep 29, 2009 IP
  4. Your Lover For Ever

    Your Lover For Ever Peon

    Messages:
    172
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    So is there any risk, or am I have to do only this solution?

    Thank you for help
     
    Your Lover For Ever, Sep 29, 2009 IP
  5. dren

    dren Active Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #5
    There's no risk with adding the .htaccess rule, but whenever people access that area of your site it will be rewritten from the .html to without it. However, if in the future you have .html files in that directory they will be rewritten also.

    So your .htaccess maybe looks like this...

    RewriteEngine On
    RewriteRule ^wallpaper/(.*)\.html$ wallpaper/$1 [L]
     
    dren, Sep 29, 2009 IP
  6. MikeDVB

    MikeDVB Peon

    Messages:
    113
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Just make sure the rewrite is right or you can end up with some strange issues :)
     
    MikeDVB, Sep 29, 2009 IP
  7. Azkaban

    Azkaban Peon

    Messages:
    537
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #7
    It's correct... I'm getting good at it :D
    Tested it for various inputs at the following link (offers to check RewriteRules)

    http://civilolydnad.se/projects/rewriterule/
    Code (markup):
    You can PM me if some problems arise. I'll be happy to fix them as part of my learning process :p

    EDIT:
    RewriteRule ^wallpaper/([0-9]+)\.html$ wallpaper/$1 [L]
    Code (markup):
    This 1 is better. It eliminates the risk pointed out by Dren.
    It'll only rewrite URL's like http://hostname/wallpaper/65535.html --------> http://hostname/wallpaper/65535
    and ignore http://hostname/wallpaper/abcdef.html and http://hostname/wallpaper/a12de3.html
    So, u'll be able to keep HTML files, as long as their filenames are not "all in numbers"
     
    Last edited: Sep 30, 2009
    Azkaban, Sep 30, 2009 IP
  8. dren

    dren Active Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #8
    Looks good. :)

    Nice job Azkaban.
     
    dren, Sep 30, 2009 IP
  9. Your Lover For Ever

    Your Lover For Ever Peon

    Messages:
    172
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Thanks, I'll test it and inform you with the result
     
    Your Lover For Ever, Sep 30, 2009 IP
  10. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #10
    its perfectly correct infact many bloggers even wordpress gives such type of urls
     
    Bohra, Sep 30, 2009 IP
  11. Your Lover For Ever

    Your Lover For Ever Peon

    Messages:
    172
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    :( I did it but still no change, all the wallpapers extensions still ended with a number

    That is my _htaccess after adding the rule:


    Options +FollowSymLinks
    RewriteEngine On
    #	leave just a normal / (slash) if the script is installed at root level otherwise enter it's folder here ex: /wscript (! no trailing slash)
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index\.php|install|scripts|fonts|uploads|robots\.txt|sitemap\.xml|favicon\.ico)
    
    #	if wscript is installed in a subfolder, add it before index.php ex: RewriteRule ^(.*)$ /wscript/index.php?/$1 [L] otherwise leave it as is
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    RewriteRule ^wallpaper/([0-9]+)\.html$ wallpaper/$1 [L]
    PHP:
    :confused:
     
    Your Lover For Ever, Sep 30, 2009 IP
  12. dren

    dren Active Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #12
    Try

    RewriteRule ^wallpaper/([0-9]+)\.html$ /wallpaper/$1 [L]
     
    dren, Sep 30, 2009 IP
  13. Your Lover For Ever

    Your Lover For Ever Peon

    Messages:
    172
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    I did it too..
    That is it:

    Options +FollowSymLinks
    RewriteEngine On
    #   leave just a normal / (slash) if the script is installed at root level otherwise enter it's folder here ex: /wscript (! no trailing slash)
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index\.php|install|scripts|fonts|uploads|robots\.txt|sitemap\.xml|favicon\.ico)
    
    #   if wscript is installed in a subfolder, add it before index.php ex: RewriteRule ^(.*)$ /wscript/index.php?/$1 [L] otherwise leave it as is
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    RewriteRule ^wallpaper/([0-9]+)\.html$ /wallpaper/$1 [L]
    PHP:
    And still no good news :(
     
    Your Lover For Ever, Sep 30, 2009 IP
  14. netvisao

    netvisao Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    So, u'll be able to keep HTML files, as long as their filenames are not "all in numbers"
     
    netvisao, Sep 30, 2009 IP
  15. Your Lover For Ever

    Your Lover For Ever Peon

    Messages:
    172
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    So, is it complicated to this extent! there is no solutions!!!
     
    Your Lover For Ever, Oct 3, 2009 IP
  16. dren

    dren Active Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #16
    Comment out your other code and just work on this one area:

    Once you get that to work uncomment your other code line by line to debug. Leave RewriteEngine On.
     
    dren, Oct 3, 2009 IP
  17. Your Lover For Ever

    Your Lover For Ever Peon

    Messages:
    172
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    I tried to work with that :

    Options +FollowSymLinks
    RewriteEngine On
    #	leave just a normal / (slash) if the script is installed at root level otherwise enter it's folder here ex: /wscript (! no trailing slash)
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index\.php|install|scripts|fonts|uploads|robots\.txt|sitemap\.xml|favicon\.ico)
    
    #	if wscript is installed in a subfolder, add it before index.php ex: # RewriteRule ^(.*)$ /wscript/index.php?/$1 [L] otherwise leave it as is
    # RewriteRule ^(.*)$ /index.php?/$1 [L]
    RewriteRule ^wallpaper/([0-9]+)\.html$ /wallpaper/$1 [L]
    PHP:
    And even that:

    Options +FollowSymLinks
    RewriteEngine On
    #	leave just a normal / (slash) if the script is installed at root level otherwise enter it's folder here ex: /wscript (! no trailing slash)
    # RewriteBase /
    # RewriteCond %{REQUEST_FILENAME} !-f
    # RewriteCond %{REQUEST_FILENAME} !-d
    # RewriteCond $1 !^(index\.php|install|scripts|fonts|uploads|robots\.txt|sitemap\.xml|favicon\.ico)
    
    #	if wscript is installed in a subfolder, add it before index.php ex: # RewriteRule ^(.*)$ /wscript/index.php?/$1 [L] otherwise leave it as is
    # RewriteRule ^(.*)$ /index.php?/$1 [L]
    RewriteRule ^wallpaper/([0-9]+)\.html$ /wallpaper/$1 [L]
    PHP:
    But I just have the same issue, I entered my homepage and opened one of my pics and the link showed like that:
    http://Mys site/index.php?/wallpapers[COLOR="Red"]/show/556[/COLOR]
    Code (markup):
    Which mean, there is no difference.
    !!!
     
    Your Lover For Ever, Oct 3, 2009 IP
  18. dren

    dren Active Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #18
    well originally you said it was
    now you're saying it's
    [quote ]
    http://Mys site/index.php?/wallpapers[COLOR="Red"]/show/556[/COLOR]
    Code (markup):
    [/quote]
    so that's obviously the problem you need to fix your rewrite
     
    dren, Oct 3, 2009 IP
  19. dren

    dren Active Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #19
    it needs to have the /wallpaper/show there
     
    dren, Oct 3, 2009 IP
  20. Your Lover For Ever

    Your Lover For Ever Peon

    Messages:
    172
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #20
    Sorry.. I didn't know that it was something important.
    Could you please tell me if the new appropriate rule would be:
    RewriteRule ^wallpapers/show/([0-9]+)\.html$ /wallpapers/show/$1 [L]
    Code (markup):
    Or something else!!
     
    Your Lover For Ever, Oct 4, 2009 IP