charlie
charlie

Reputation: 1384

htaccess Rewrite for $_GET in PHP

i currently have this in my htaccess file

RewriteRule ^([a-zA-Z0-9\-]+)$ pages/$1.php

so when you go to the url http://www.domain.com/services it will go to the page pages/services.php

i want to be able to have

http://www.domain.com/services/service1

which will go to pages/services.php?seq=<?php echo $_GET["seq"]; ?>

How can I do this using htaccess Rewrite rule?

Upvotes: 0

Views: 58

Answers (1)

Iłya Bursov
Iłya Bursov

Reputation: 24146

add this rule before main one:

RewriteRule ^/{0,1}services/(service[0-9]+)/{0,1}$ pages/services.php?seq=$1  [NE,NC,L]

UPDATE:

if you need only numeric part of service### - use:

RewriteRule ^/{0,1}services/service([0-9]+)/{0,1}$ pages/services.php?seq=$1  [NE,NC,L]

note position of "("

Upvotes: 2

Related Questions