Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can !
Moderator: General Moderators
alex.barylski
DevNet Evangelist
Posts: 6267 Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg
Post
by alex.barylski » Sat Nov 04, 2006 9:16 pm
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
timvw
DevNet Master
Posts: 4897 Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium
Post
by timvw » Sat Nov 04, 2006 10:30 pm
(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...
alex.barylski
DevNet Evangelist
Posts: 6267 Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg
Post
by alex.barylski » Sun Nov 05, 2006 11:49 am
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?
timvw
DevNet Master
Posts: 4897 Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium
Post
by timvw » Sun Nov 05, 2006 1:26 pm
i wanted to say that i was not sure that an url like test.php?id=a#foo would be matched...
itsmani1
Forum Regular
Posts: 791 Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:
Post
by itsmani1 » Mon Nov 06, 2006 3:54 am
need rule that can send
/xxxxxx/111111/abc.html to index.php?cid=111111
any help in the rule?
thanks
timvw
DevNet Master
Posts: 4897 Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium
Post
by timvw » Mon Nov 06, 2006 6:06 am
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?