.htaccess files really aren't my thing. They still remain a mystery to me and probably will always be...
Anyway, so I have an .htaccess file with quite some rewrite rules for all different pages.
URL: http://placeholder.com/OC/hoig/[page]
Folder structure:
- Index (news): http://placeholder.com/OC/hoig/index.php
- Partners: http://placeholder.com/OC/hoig/partners.php
- Contact: http://placeholder.com/OC/hoig/contact.php
- Leerinhoud (yeah, it's Dutch): http://placeholder.com/OC/hoig/leerinhoud.php
- Search: http://placeholder.com/OC/hoig/search.php?q=test
The goal is to get semantic (pretty) URL's for all pages. Right now, this .htaccess file works partly. Almost all pages get a pretty URL, except 'Leerinhoud detail'. For some reason, it returns content from 'Leerinhoud' but under a pretty url (http://placeholder.com/OC/hoig/leerinhoud/1/the-slug).
Also, I'm not so sure about the [R=302,L] flag because that's a temporary redirect, which I don't really need.
GOAL
http://placeholder.com/OC/hoig/index.php to http://placeholder.com/OC/hoig/
http://placeholder.com/OC/hoig/leerinhoud.php to http://placeholder.com/OC/hoig/leerinhoud
http://placeholder.com/OC/hoig/leerinhoud-detail.php?id=1&leerinhoud=the-slug to http://placeholder.com/OC/hoig/leerinhoud/1/the-slug
...
.htaccess:
RewriteEngine On
RewriteBase /OC/hoig/
RewriteCond %{THE_REQUEST} /news-detail\.php\?id=([^\s&]+)&news=([^\s&]+) [NC]
RewriteRule ^ nieuws/%1/%2? [R=302,L]
RewriteRule ^nieuws/([^/]+)/([^/]+)/?$ news-detail.php?id=$1&news=$2 [L,NC,QSA]
RewriteCond %{THE_REQUEST} /leerinhoud\.php [NC]
RewriteRule ^ leerinhoud [R=302,L]
RewriteRule leerinhoud leerinhoud.php [L,NC,QSA]
RewriteCond %{THE_REQUEST} /leerinhoud-detail\.php\?id=([^\s&]+)&leerinhoud=([^\s&]+) [NC]
RewriteRule ^ leerinhoud/%1/%2? [R=302,L]
RewriteRule ^leerinhoud/([^/]+)/([^/]+)/?$ leerinhoud-detail.php?id=$1&leerinhoud=$2 [L,NC,QSA]
RewriteCond %{THE_REQUEST} /partners\.php [NC]
RewriteRule ^ partners [R=302,L]
RewriteRule partners partners.php [L,NC,QSA]
RewriteCond %{THE_REQUEST} /contact\.php [NC]
RewriteRule ^ contact [R=302,L]
RewriteRule contact contact.php [L,NC,QSA]
# RewriteCond %{THE_REQUEST} /search\.php\?q=([^\s&]+) [NC]
# RewriteRule ^ search-results/%1? [R=302,L]
# RewriteRule search-results/([^/]+)/?$ search.php?q=$1 [L,NC,QSA]
RewriteCond %{THE_REQUEST} /rss-detail\.php\?rss=([^\s&]+) [NC]
RewriteRule ^ rss/%1? [R=302,L]
RewriteRule rss/([^/]+)/?$ rss-detail.php?rss=$1 [L,NC,QSA]
RewriteCond %{THE_REQUEST} /tags\.php [NC]
RewriteRule ^ tags [R=302,L]
RewriteRule tags tags.php [L,NC,QSA]
RewriteCond %{THE_REQUEST} /tag\.php\?tag=([^\s&]+) [NC]
RewriteRule ^ tag/%1? [R=302,L]
RewriteRule tag/([^/]+)/?$ tag.php?tag=$1 [L,NC,QSA]
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^ nieuws [R=302,L]
RewriteRule nieuws index.php [L,NC,QSA]
TL;DR: How can I get some kickass clean SEO-friendly URL's for all my pages?
Thanks in advance.