Page 1 of 1
complicated mod_rewrite
Posted: Sat Nov 04, 2006 9:16 pm
by alex.barylski
Is there a way based on the extension of a URL (PHP or HTML) you can redirect the URL and it's parts accordingly???
some_title.html = index.php?page=some_title
some_script.php = index.php?script=some_script
Can you please show me the exact regex required for this?
Code: Select all
#RewriteEngine on
#RewriteRule ^([^/\.]+)/?$ index.php?url=$1 [L]
The above works on recognizing preceeding folders but I need to match the extensions I assume for the to work and use some kind of conditional magic???
Cheers

Re: complicated mod_rewrite
Posted: Sat Nov 04, 2006 10:30 pm
by timvw
(untested)
RewriteRule ^(.*?)\.html$ /index.php?page=$1 [L]
RewriteRule ^(.*?)\.php$ /index.php?script=$1 [L]
probably needs some improvement to allow anchors in the url...
Re: complicated mod_rewrite
Posted: Sun Nov 05, 2006 11:49 am
by alex.barylski
timvw wrote:(untested)
RewriteRule ^(.*?)\.html$ /index.php?page=$1 [L]
RewriteRule ^(.*?)\.php$ /index.php?script=$1 [L]
probably needs some improvement to allow anchors in the url...
Cool thanks timvw...one question, by anchors you mean?
Posted: Sun Nov 05, 2006 1:26 pm
by timvw
i wanted to say that i was not sure that an url like test.php?id=a#foo would be matched...
Posted: Mon Nov 06, 2006 3:54 am
by itsmani1
need rule that can send
/xxxxxx/111111/abc.html to index.php?cid=111111
any help in the rule?
thanks
Posted: Mon Nov 06, 2006 6:06 am
by timvw
itsmani1 wrote:need rule that can send
/xxxxxx/111111/abc.html to index.php?cid=111111
Shouldn't you have learned not to hijack threads by now?
What have you tried so far?
And what was your reasoning behind the attempts?