Forum Moderators: phranque

Message Too Old, No Replies

Mod Rewrite Help

Need help figuring the code

         

bbott

6:16 pm on Apr 28, 2005 (gmt 0)

10+ Year Member



I have a directory and the link appear like this:

http://www.example.com/?c=1
http://www.example.com/?c=220
etc...

I need them to appear like this:

http://www.example.com/1
http://www.example.com/220

If you could help me out i'd really apreciate it.

[edited by: jdMorgan at 3:24 pm (utc) on May 2, 2005]
[edit reason] Removed specifics per TOS. [/edit]

jd01

8:19 pm on Apr 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi bbot,

If you start with this link:
[webmasterworld.com...]

read the thread.

then follow the link in the thread, you should have a better answer and know more than I have time to type right now.

Hope this helps... should get you started and help you clarify how the whole process works.

Justin

bbott

2:29 am on Apr 29, 2005 (gmt 0)

10+ Year Member



Hmm, that didn't really help. Whatever I try is not working...

Anyone have any ideas?

jd01

2:44 am on Apr 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok, first idea...

You're going the wrong way...

You have to link from your pages to the new 'friendly' URL's that do not exist, then through the use of mod_rewrite, you can tell your server to serve the static request from the dynamic page.

Your rewrite may very well look something like this:

RewriteEngine on
RewriteRule ^([0-9]+)$ /?c=$1 [L]

or if you prefer to go to a specific page name:

RewriteEngine on
RewriteRule ^([0-9]+)$ /page.php?c=$1 [L]

^ start here
() create a variable.
[0-9] any number between 0 and 9.
+ 1 or more of the immediately preceding.
$ stop matching

/page.php start from the root and go to here.
?c= add a query string.
$1 add the variable I previously stored.
[L] stop processing now.

Maybe I got the wrong thread, I thought that one explained the format of the links. EG fake vs real pages.

Hope this helps.

Justin