Forums

Any .htaccess geniuses out there? (3 posts)

  1. richarduk
    Member
    Posted 4 months ago #

    Bit of an advanced question, possibly, but here goes.

    I have a shopping cart within a WP installation

    I've found some mod rewrite code that will change the urls of the shopping cart to nicer-looking urls

    http://www.mysite.co.uk/proddetail.php?prod=monitor

    goes to

    http://www.mysite.co.uk/monitor

    However, this now rewrites the single posts in WordPress and sends me back into the shopping cart error page.

    Has anyone got the skill to disentangle this problem for me?

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule ^([A-Za-z0-9]+)(/)?$ proddetail.php?prod=$1 [L]
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /proddetail\.php\?prod=([^&]+)\ HTTP/
    RewriteRule ^proddetail\.php$ http://www.mysite.co.uk/%1? [R=301,L]
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
  2. Shane G
    Member
    Posted 4 months ago #

    Hi,

    Add this in htaccess:

    # BEGIN WordPress

    <IfModule mod_rewrite.c>
    ErrorDocument 404 /index.php?error=404
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress

    Thanks,

    Shane G.

  3. richarduk
    Member
    Posted 4 months ago #

    Thanks Shane, that didn't work but I got round it by creating a different custom permalink structure /%postname%.php

    Somehow, by pot luck, that did it.

    Now I've discovered that the cart code produces a url without a trailing slash. If I add a trailing slash I get a duplicate page. How can I make non-trailing slash and a trailing slash resolve to the same page?

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule ^([A-Za-z0-9]+)(/)?$ proddetail.php?prod=$1 [L]
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /proddetail\.php\?prod=([^&]+)\ HTTP/
    RewriteRule ^proddetail\.php$ http://www.mysite.co.uk/%1? [R=301,L]

Reply

You must log in to post.

About this Topic

Tags