1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Page slugs

Discussion in 'Templates, HTML, CSS, and Design Help' started by BlackWebs, May 20, 2014.

  1. BlackWebs New Member

    Hello,

    I'd like to know if it is possible to remove .html from the pages - I've tried various things with the htaccess and SEO plugin without success, getting the feeling it's a lot more involved than that...

    Thanks
    Tom
  2. Mike-N-Tosh Owner

    I'm not sure exactly what/why you would want to do this, however you would need to modify two files.

    seo/hooks.php and the .htaccess.

    These files work hand in hand and for each change you make in the hooks file would then have to be reflected in the htaccess file accordingly. The forum is not a place where I would try to teach you all about module_rewrite and if you want to learn more about it, then there's plenty of information on the net by searching for htaccess, mod rewrite, etc..

    I'll give you an example to use and then you can take it from there for your specific purposes. Let's use the search function in 68 Classifieds.

    In the "hooks.php" file find the search.html line in the rewrite_url function around line 149. Now just delete the ".html" part. (the rewrite_url function is what tells the smarty template system to write the links on the page that is rendered, so as it was before the change, any http://yoursite/search.php link would be written as http://yoursite/search.html). Now all of those will be set to simply "/search".

    Now for the website server to understand what that url is (because it doesn't actually exist) is where you change the .htaccess file to tell the server what the real file you want to load is.

    So, in this case, find the RewriteRule for the search around line 13 in the .htaccess file.
    RewriteRule ^search\.html$ search.php [NC,QSA]
    The part before the space is what the URL that it is looking for (after the domain name, e.g. yoursite.com/). It is set to look for search.html (which will never happen now that we've change it). So we need to set it to what we now have set those links for search to, which is just search. So it should be changed to be.
    RewriteRule ^search$ search.php [NC,QSA]
    Save both files and go to your home page and notice that the "Search" link will now be for simply "search" and if you click on it, the new url will be for just yoursite/search, but the actual yoursite/search.php file will actually be used.

    So use the same methodology for each of the urls that you want to get rid of the ".html" for. I would strongly recommend that you do one at a time in both files save and test.

    Good luck.
  3. BlackWebs New Member

    Hi Mike,

    I appreciate your help with this - I will give it a go and post back.

    Thanks
    Tom

Share This Page