WordPress URL Parameters on GoDaddy

I am currently making a website (http://tannernelson.me/ehs)

It’s hosted on Godaddy, and I’m using wordpress as a CMS.

Read More

I want to be able to make:

http://tannernelson.me/ehs/school/academics/teachers/jsmith

turn into

http://tannernelson.me/ehs/index.php?pagename=teachers&detail=jsmith

So, basically, if there are 4 segments to the url (school/academics/teachers/jsmith) I want the last one to be a variable. So the fourth segment of any url will be the variable “detail”

My current URL rewrite is currently

# Mod Rewrite
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /ehs/index.php [L]
Options -Multiviews

It won’t work any other way, even with the default WordPress .htaccess file. And I have no idea what that means, or what kind of request URI is made out of it. It’s really confusing.

Any ideas?

Related posts

Leave a Reply

1 comment

  1. The code you have right now means:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    

    If the requested filename is not (!) a regular file -f and if the requested filename is not (!) a directory -d then:

    RewriteRule . /ehs/index.php [L]
    

    Match any single character (.) and if a match is found rewrite the URL to /ehs/index.php and then make this the last rule ([L]) so don’t process any further rules.

    This doesn’t look like what you want, but seems to be working. http://tannernelson.me/ehs/school/academics/teachers/jsmith serves up (I think) http://tannernelson.me/ehs/index.php because I get a custom 404 not found page.

    Try the following .htaccess code:

    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    
    # Redirect the ehs/school/academics/$1/$2 URIs to /ehs/index.php?pagename=$1&detail=$2
    RewriteRule ^ehs/school/academics/([^/]+)/([^/]+)$ /ehs/index.php?pagename=$1&detail=$2 [L]
    
    # Otherwise if the requested URI is not found (not a file nor a directory)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    #Redirect everything else to index.php
    RewriteRule .* /ehs/index.php [L]
    
    Options -Multiviews
    

    I just tested this on my Apache server and it works.