rewriting urls not working

Discuss practical ways rearrange URLs using mod_rewrite.

rewriting urls not working

Postby hackie » Wed Jun 09, 2004 1:34 pm

any ideas?

Code: Select all
RewriteRule ^forum.php\?\f=([0-9]*)&topicdays=([0-9]*)&start=([0-9]*).*$ /viewforum.php?f=$1&topicdays=$2&start=$3
RewriteRule ^forum.php\?\f=([0-9]*)&mark=true$ /viewforum.php?f=$1&mark=topic
RewriteRule ^forum.php\?\f=([0-9]*)$ /viewforum.php?f=$1

RewriteRule ^topic.php\?\t=([0-9]*)?mode=previous$ /viewtopic.php?t=$1&view=previous
RewriteRule ^topic.php\?\t=([0-9]*)?mode=next$ /viewtopic.php?t=$1&view=next
RewriteRule ^topic.php\?\t=([0-9]*)?mode=newest$ /viewtopic.php?t=$1&view=newest
RewriteRule ^topic.php\?\t=([0-9]*)&postdays([0-9]*)&postorder=([a-zA-Z]*)&start=([0-9]*)$ /viewtopic.php?t=$1&postdays=$2&postorder=$3&start=$4
RewriteRule ^topic.php\?\t=([0-9]*)&start=([0-9]*)&postdays=([0-9]*)&postorder=([a-zA-Z]*)&highlight=([a-zA-Z]*)$ /viewtopic.php?t=$1&start=$2&postdays=$3&postorder=$4&highlight=$5
RewriteRule ^topic.php\?\t=([0-9]*)&start=([0-9]*)$ /viewtopic.php?t=$1&start=$2
RewriteRule ^topic.php\?\t=([0-9]*)$ /viewtopic.php?t=$1
RewriteRule ^topic.php\?\p=([0-9]*)$ /viewtopic.php?p=$1


Trying to get it to rewrite stuff for phpBB. I already got the mod_rewrite modification installed, and changed all the stuff for it to work, but it wont work.

help me, plz! :confused:
hackie
 

Postby seomike » Wed Jun 09, 2004 6:02 pm

What you need to do is change the links on the php pages to output a static URL string for example the first rewrite rule

the current URL string would look something like this:

/viewforum.php?f=1&topicdays=25&start=5

You can now change that to what ever you want as long as you keep the variables in the URL somewhere. example:

forum1/topic25-5.html

Then you go into the .htaccess files and change the mod write from this

Code: Select all
RewriteRule ^forum.php\?\f=([0-9]*)&topicdays=([0-9]*)&start=([0-9]*).*$ /viewforum.php?f=$1&topicdays=$2&start=$3


to this to find the variables and parse them out and then put them into the query.
Code: Select all
RewriteRule ^forum([0-9]*)/topic([0-9]*)-([0-9]*)\.html$ /viewforum.php?f=$1&topicdays=$2&start=$3


right now your mod is making your server work harder then necessary.

A mod parses out the variable in a static url and then plugs the back into their original query string and sends it off to the php engine to be processed. What your current code is doing is parsing the variables out of a dynamic string and then plugging them back into the same string.
seomike
 
Posts: 331
Joined: Thu May 06, 2004 7:36 pm
Location: Dallas


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 21 guests

cron