Reputation: 3269
I have the following url:
http://www.domain.gr/add-event?state=3cb7a28b14112d3f3ecada3d6915ac5f&code=AQAZeWtJgz1ZYWvsorRPiMRetkNhnU3NrQ9KYzIRkogUpg6IPHCkFCAWMBUYGYtulfWnr5JHWs2GbrBUAp89pVLStyKs_rer2r14yLI6qdByoqEv1TtHGK4TPzdLFRTgXZEzPEUyk9ixYQfdmZid0dRdTfVXDPqniCKnu8RHQb1ErRDezsdI2CcYsTxofe_wwtZYVD3d4r9VtlANrGn_klP1#_=_
My RewriteRule works fine with urls like http://www.doamin.gr/news/date/title-of-article setting 'news' as $_GET['page'] and $_GET['request'] to '/date/title-of-article' My htaccess has the following code in order to provide clean urls:
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)(.*)$ /index.php?page=$1&request=$2
With the above url $_GET is set as follows:
$_GET['page'] = 'add-event'; $_GET['request'] = ''; // blank
How should I modify the reqriteRule in order to get the remaining part of the url in this case?(without messing up my clean urls).
Upvotes: 1
Views: 448
Reputation: 38044
Your first sub-pattern ([^/]*)
is a greedy pattern. This means that the expression will match the largest possible substring of the input string (and since the expression matches everything except the /
character, it will match the entire string -- subsequently, the second sub-pattern will not match anything).
You can mark the subpattern as non-greedy or lazy (i.e. ([^/]*?)
), but then it will match only the /
character. You could modify the pattern to match everything up to the beginning of the query part of the URL: ^([^/]*?)\?
Upvotes: -1