Forums

Permalink dynamic pages .htaccess (4 posts)

  1. Jalet
    Member
    Posted 1 month ago #

    On my wordpress site a have a few pages. On one page i present the content depending on $_GET['ID':
    http://www.schoolsout.se/site/hitta-studentskiva?eventID=0000000013

    I want the URL to be like this:
    http://www.schoolsout.se/site/hitta-studentskiva/0000000013.html

    But I can't make it work. In the .htaccess I have added this line:

    RewriteEngine On
    RewriteRule ^site/hitta-studentskiva/([^/]*)\.html$ /site/hitta-studentskiva?eventID=$1 [L]

    So now it looks like this:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /site/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /site/index.php [L]
    </IfModule>
    
    # END WordPress
    
    RewriteEngine On
    RewriteRule ^site/hitta-studentskiva/([^/]*)\.html$ /site/hitta-studentskiva?eventID=$1 [L]

    I haven't worked with mod rewrite earlier.

  2. mfields
    Member
    Posted 1 month ago #

    Jalet - you need to place your custom line above the code that WordPress generates. Basically, the WordPress code says "If the request is not actually a file or folder - send the request to index.php for processing".

  3. Jalet
    Member
    Posted 1 month ago #

    Ok, i tried like this, but it still wont work :(

    RewriteEngine On
    RewriteRule ^site/hitta-studentskiva/([^/]*)$ /site/hitta-studentskiva/?eventID=$1 [L]
    
    <IfModule mod_rewrite.c>
    #
    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /site/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /site/index.php [L]
    </IfModule>
    
    # END WordPress
  4. mfields
    Member
    Posted 4 weeks ago #

    Problem is most likely with your regex, maybe this will work?

    RewriteRule ^site/hitta-studentskiva/([0-9]{10})$ /site/hitta-studentskiva/?eventID=$1 [L]

Reply

You must log in to post.

About this Topic