SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jun 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Redirects not working alongside Dynamic URL's

    Hi all, I have an issue with an OpenCart Redirect file, I am new to OpenCart and 301 redirects.

    There are 2 kinds of redirect going on in the file, one is the part for the SEO friendly URLs but this site existed before and has transferred to OpenCart so the there are individual Google link redirects going on as well.

    I managed to get the google redirects working by deleting the QSA from the last Redirect rule but this had other ramifications – the query strings for which page of products the user is on would then be ignored and they would be stuck on page 1.

    Is there a way I can get the google links redirected to the appropriate pages and have the SEO friendly URLs on once they’re in the site.

    Thank you, see below for a slightly butchered htaccess file )

    Dave

    P.s i've added a space in the url's below because of the forum rules.

    ********************htaccess file begin*************************

    # 1.To use URL Alias you need to be running apache with mod_rewrite enabled.

    # 2. In your opencart directory rename htaccess.txt to .htaccess.

    # For any support issues please visit: http://www. opencart.com

    Options +FollowSymlinks

    # Prevent Directoy listing
    Options -Indexes

    # Prevent Direct Access to files
    <FilesMatch "\.(tpl|ini)">
    Order deny,allow
    Deny from all
    </FilesMatch>

    # SEO URL Settings
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    Redirect 301 /page/4534098781 http://www .uktrailerparts.co.uk/Load-Restraint-Equipment
    Redirect 301 /page/4534098640 http://www. uktrailerparts.co.uk/Curtain-Tensioners
    Redirect 301 /tir-cords/4534098782 http://www. uktrailerparts.co.uk/TIR-Cords-TIR-Cables-TIR-Tooling

    RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]

    ********************htaccess file end*************************

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,653
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Hi Dave!

    First, OpenCart has nothing to do with mod_rewrite except to use it (like PHP). From what you've shown, they use the same (generic) code that WordPress uses (and I suspect that you were smart enough to remove the <IfModule> wrapper WP uses to protect ID-ten-T "webmasters" - and I use that term VERY loosely!).

    Without any example of your SEO URLs, I can't comment on those, however, I doubt that the QSA would have impacted those at all.

    When quoting code, please use [ code ] ... [ /code ] wrappers (without the interior spaces) as the code will be preserved (without making URLs clickable) and without any problem from staff for infractions - that's NOT infractable.
    Code:
    # .htaccess file begin
    
    # 1.To use URL Alias you need to be running apache with mod_rewrite enabled.
    
    Alias has NOTHING to do with mod_rewrite! Who came up with that comment?
    # 2. In your opencart directory rename htaccess.txt to .htaccess.
    .htaccess IS the correct filename (at least on Apache servers)
    # For any support issues please visit: http://www. opencart.com Options +FollowSymlinks
    That should already be in your server's configuration file (NOT necessary here).
    # Prevent Directoy listing Options -Indexes
    Ditto
    # Prevent Direct Access to files <FilesMatch "\.(tpl|ini)"> Order deny,allow Deny from all </FilesMatch>
    That should have included the .htaccess file - but no matter
    # SEO URL Settings Redirect 301 /page/4534098781 http://www.uktrailerparts.co.uk/Load...aint-Equipment Redirect 301 /page/4534098640 http://www.uktrailerparts.co.uk/Curtain-Tensioners Redirect 301 /tir-cords/4534098782 http://www.uktrailerparts.co.uk/TIR-...es-TIR-Tooling
    Moved before mod_rewrite as these are mod_alias directives, i.e., part of the Apache core so they take place before mod_rewrite.
    RewriteEngine On RewriteBase /
    ONLY useful is you have mod_alias Redirects that must be UNdone before mod_rewrite can work on them!
    RewriteCond &#37;{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]
    ERROR! I believe you're trying to access a query string here with the escaped ? because that's just NOT possible. Because this regex makes no sense, you SHOULD be getting a parse error from mod_rewrite which SHOULD result in 500 errors. All you're after is NOTHING or EVERYTHING for which the :kaioken: EVERYTHING :kaioken: atom is used (and the NOT file and NOT directory eliminate potential looping).
    # .htaccess file end
    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

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