Mod Rewrite > geen / verplichten
Dus dat de url in plaats van: http://domein.nl/modules/id/ ook http://domein.nl/modules/id kan gebruiken?
Ik gebruik nu deze code:
Code (php)
1
2
3
4
5
6
2
3
4
5
6
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)/(.*)/(.*)$ index.php?pgs=$1&act=$2&id=$3 [L]
RewriteRule ^(.*)/(.*)$ index.php?pgs=$1&act=$2 [L]
RewriteRule ^(.*)$ index.php?pgs=$1 [L]
RewriteBase /
RewriteRule ^(.*)/(.*)/(.*)$ index.php?pgs=$1&act=$2&id=$3 [L]
RewriteRule ^(.*)/(.*)$ index.php?pgs=$1&act=$2 [L]
RewriteRule ^(.*)$ index.php?pgs=$1 [L]
Staat wel een slash in je laatste parameter dan, ik ben niet zo'n kei in regex, maar dit zou de oplossing kunnen zijn:
Helaas beide werken niet :(
Code (php)
1
2
3
4
5
6
2
3
4
5
6
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)/(.*)/(.*)/?$ index.php?pgs=$1&act=$2&id=$3 [L]
RewriteRule ^(.*)/(.*)/?$ index.php?pgs=$1&act=$2 [L]
RewriteRule ^(.*)/?$ index.php?pgs=$1 [L]
RewriteBase /
RewriteRule ^(.*)/(.*)/(.*)/?$ index.php?pgs=$1&act=$2&id=$3 [L]
RewriteRule ^(.*)/(.*)/?$ index.php?pgs=$1&act=$2 [L]
RewriteRule ^(.*)/?$ index.php?pgs=$1 [L]
Het vraagteken staat voor "match nul of één maal", en dat is volgens mij wat je zoekt.
"Internal Server Error"
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
RewriteEngine On
RewriteBase /
# no slash
RewriteRule ^([^./]+)?$ index.php?pgs=$1 [L]
RewriteRule ^([^./]+)/([^./]+)?$ index.php?pgs=$1&act=$2 [L]
RewriteRule ^([^./]+)/([^./]+)/([^./]+)?$ index.php?pgs=$1&act=$2&id=$3 [L]
# with slash
RewriteRule ^([^./]+)/?$ index.php?pgs=$1 [L]
RewriteRule ^([^./]+)/([^./]+)/?$ index.php?pgs=$1&act=$2 [L]
RewriteRule ^([^./]+)/([^./]+)/([^./]+)/?$ index.php?pgs=$1&act=$2&id=$3 [L]
RewriteBase /
# no slash
RewriteRule ^([^./]+)?$ index.php?pgs=$1 [L]
RewriteRule ^([^./]+)/([^./]+)?$ index.php?pgs=$1&act=$2 [L]
RewriteRule ^([^./]+)/([^./]+)/([^./]+)?$ index.php?pgs=$1&act=$2&id=$3 [L]
# with slash
RewriteRule ^([^./]+)/?$ index.php?pgs=$1 [L]
RewriteRule ^([^./]+)/([^./]+)/?$ index.php?pgs=$1&act=$2 [L]
RewriteRule ^([^./]+)/([^./]+)/([^./]+)/?$ index.php?pgs=$1&act=$2&id=$3 [L]
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?pgs=$1&act=$2&id=$3 [L]
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?pgs=$1&act=$2 [L]
RewriteRule ^([^/]+)/?$ index.php?pgs=$1 [L]