Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Zaphod

    (@zaphod)

    Have made a very poor start on this.

    Have created a dummy site non-wordpress site on my local machine using a .html file, one or two php files etc.

    in the .htaccess file I put

    RewriteRule ^used-cars/([0-9a-zA-Z]*)$ /used-cars/$1/
    RewriteRule ^used-cars/([0-9a-zA-Z]*)/$ /ht/?make=$1

    so if I enter
    https://localhost/ht/used-cars/Abjh4/ #URL FOR DEMO ONLY – WON’T WORK

    it shows up as such in the browser but looks for :
    /mypage.php?make=Abjh4
    SO AS SUCH, IT WORKS.

    TWO THINGS.

    1) Above example: can’t figure out how to get it to work as follows:
    https://localhost/ht/used-cars/ford/fiesta/
    to show above url but look for
    /mypage.php?make=ford&model=fiesta

    2)If I add this [two rewrite rules above] to the WordPress .htaccess file after the
    # END WordPress
    bit, it makes no difference whatsoever.

    So I need a heads up on how to get a rule that I know works (in one sense) to work with the WP rules and not break anything.

    2)

    Thread Starter Zaphod

    (@zaphod)

    Small update to the above:

    RewriteRule ^used-cars/([0-9a-zA-Z_-]*)/([0-9a-zA-Z_-]*)$ /used-cars/$1/$2/
    RewriteRule ^used-cars/([0-9a-zA-Z_-]*)/([0-9a-zA-Z_-]*)/$ /ht/?make=$1&model=$2

    works to turn
    https://localhost/ht/used-cars/ford/fiesta/
    into (on server end)
    /mypage.php?make=ford&model=fiesta

    ** BUT ** it breaks if I just put

    https://localhost/ht/used-cars/ford/

    saying
    Not Found

    The requested URL /used-cars/ford// was not found on this server.
    *note* TWO trailing slashes at the end…

    One step forward, and two steps back…

    Thread Starter Zaphod

    (@zaphod)

    Just FYI here’s my .htaccess

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /mysite/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    #RewriteRule . /carcompare/index.php [L] L denotes LAST - i.e. dont' follow any more Rewrite Rules
    RewriteRule . /mysite/index.php 
    
    </IfModule>
    
    # END WordPress
    
    #RewriteRule ^old\.html$ new.html  THIS ONE WORKS
    RewriteRule ^used-cars/([0-9a-zA-Z_-]*)/([0-9a-zA-Z_-]*)$ /used-cars/$1/$2/
    RewriteRule ^used-cars/([0-9a-zA-Z_-]*)/([0-9a-zA-Z_-]*)/$ /ht/?make=$1&model=$2
    Thread Starter Zaphod

    (@zaphod)

    In the above example normal WP rules work fine, my redirection rules being ignored. The /ht/ bit on the last line is wrong but I’m aware of that – that’s not the issue.

    Thread Starter Zaphod

    (@zaphod)

    …. is there anybody out there….

    ??

    Maybe this just can’t be done?

    let me know if you find some solution for this.

    Thanks,
    Arpita

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Permalinks and mod_rewrite – how to make query url look like directory’ is closed to new replies.