I am currently trying to set up a rewrite rule to set up an internal redirect for a more SEO-friendly url-structure.
I want to show:
/find-teacher/primary-school.php
instead of the sad looking:
/find-teacher/subject-class-choose.php?school=primary-school
After I read some posts and tutorials about the rewrite rule and rewrite cond, I came up with this:
In my choose-school.php I have as a link with the nice looking url:
<a href="https://www.example.com/find-teacher/primary-school.php">
Primary School</a>
In my .htaccess:
RewriteCond %{REQUEST_URI} ^find-teacher/primary-school.php$
RewriteRule ^find-teacher/([a-z-]+)-([0-9]+).php$ /find-teacher/subject-class-choose.php?school=$1 [NC]
Now if I got that right, the RewriteCond
part checks if the following url is requested. If that is the case, then the part of ([a-z-]+)-([0-9]+)
is replaced by the $1
of the substitution part (/find-teacher/subject-class-choose.php?school=$1
)
Problem is that I am redirected to my error page if I click on /find-teacher/primary-school.php