Need help with .htaccess

Discussion in 'Site & Server Administration' started by kalseo, Oct 11, 2012.

  1. #1
    Hi DP friends,

    Currently I am trying to make SEF URLs for the following project aidability.co.uk, however I have major problems with rewriting URLs through .htaccess. Probably I have to mention that website is hosted at 1&1, can anybody help me with some very basic .htaccess .

    Currently my .htaccess file looks like that:

    RewriteEngine On
    RewriteRule ^([^/]*)\.html$ /index.php?pagelink=$1 [i]
    RewriteRule ^([^/]*)\.html$ /category.php?category=$1 [c]
    RewriteRule ^([^/]*)\.html$ /product_detail.php?product=$1 [d]
    Code (markup):
    Kind regards
    Kal
     
    kalseo, Oct 11, 2012 IP
  2. pr0t0n

    pr0t0n Well-Known Member

    Messages:
    243
    Likes Received:
    10
    Best Answers:
    10
    Trophy Points:
    128
    #2
    Well... you have set all url rules to the same value, so each time your first rule will be applied. You might want to change your second and third rule, so each gets a little bit different. For example:
    
    RewriteEngine On
    RewriteBase /
    
    RewriteRule ^([^/]+).html$ /index.php?pagelink=$1 [L]
    RewriteRule ^category/([^/]+).html$ /category.php?category=$1 [L]
    RewriteRule ^product/([^/]+).html$ /product_detail.php?product=$1 [L]
    
    Code (markup):
    So, with this three rules, all your html links will actually open index.php page, all your category/somepagehere.html will open your category.php and all your product/blahblah.html will open product_detail.php script. You can of course change the code the way you like it, but remember that each rule has to be somehow specific, and not the same as another rewrite rule, because the server will then apply the first one it finds in htaccess.

    Cheers!
     
    pr0t0n, Oct 11, 2012 IP