Firefox PHP

Mod_Rewrite Hack

Posted by TIG 
All files from this thread

File Name File Size   Posted by Date  
sef.php 920 bytes open | download Thomas Seifert 11/29/2004 Read message
TIG
Mod_Rewrite Hack
November 28, 2004 12:20PM
Hi,
I searched, but didn't found this hack.


I would do it by myself, but i have no knowledge about the parsing-part. For a php-coder it should be a simple job.

Perhaps someone is interessted in this hack, too. It would improve usability and Google likes it.


Mod_Rewrite? Cryptic Urls become readable paths!

/list.php?1 > /offtopic/
/list.php?2 > /support/
/list.php?3 > /feedback/

/read.php?2,1 > /support/1/
/read.php?2,2 > /support/2/

/search.php > /search/
/search.php?1 > /support/search/


Thanks for your attention.
Martin.

--

My Board: [www.ddig.de]
My Mailadress: mr@ddig.de
Re: Mod_Rewrite Hack
November 28, 2004 12:31PM
thats an even more tough hack than the usual mod_rewrite changes.
usually you would do something like that:
/list.php?1 > /list/1
/list.php?2 > /list/2
/list.php?3 > /list/3

mod_rewrite doesn't know about the names and you would need to hardcode all the names therefore.

btw.: nice template there :)


Thomas Seifert
Phorum Development Team / Mysnip-Solutions.de
Custom Phorum and general software development
worry-free Phorum Hosting




Edited 1 time(s). Last edit at 11/28/2004 12:32PM by ts77.
TIG
Re: Mod_Rewrite Hack
November 28, 2004 12:43PM
Mh, ok, perhaps a good feature in Phorum 6.0 :)

Thanks for every Devoloper for this great System.

Greetings.
Re: Mod_Rewrite Hack
November 28, 2004 12:46PM
as I told, its the deficiency of mod_rewrite which doesn't know about the forum-name <-> forum-id relation.
and mod_rewrite is apache-specific ... ;).


Thomas Seifert
Phorum Development Team / Mysnip-Solutions.de
Custom Phorum and general software development
worry-free Phorum Hosting
TIG
Re: Mod_Rewrite Hack
November 28, 2004 01:06PM
> forum-name <-> forum-id
> mod_rewrite is apache-specific

oh, i thought there is eventually a way php could rewrite the .htaccesfile.

ok, i'll try it on my own. i think i just need to hack the dynamic intern linkage and adjust the .htaccess-file with my own forum-names.

time to learn more about php.

thx thomas.
Re: Mod_Rewrite Hack
November 29, 2004 12:50AM
I just did a small hack for search-engine-friendly URLs aka URLs which can be used with mod_rewrite.

Please read the instructions on top of the file, changes/corrections welcome.


Thomas Seifert
Phorum Development Team / Mysnip-Solutions.de
Custom Phorum and general software development
worry-free Phorum Hosting
Attachments:
open | download - sef.php (920 bytes)
TIG
Re: Mod_Rewrite Hack
November 29, 2004 01:23AM
yehaw, thx a lot. this will help me a lot. thx!
Re: Mod_Rewrite Hack
November 29, 2004 06:31PM
I would really like if there would be a more generic mod_rewrite ruleset which could be used with that.
I'm not used to mod_rewrite and just hacked that ruleset together ;).


Thomas Seifert
Phorum Development Team / Mysnip-Solutions.de
Custom Phorum and general software development
worry-free Phorum Hosting
Re: Mod_Rewrite Hack
December 07, 2004 11:36AM
About the ruleset. This works for me:

RewriteRule ^([^/]*)/([0-9])/([^/]*)/(.*)$ $1/$2/$3,$4
RewriteRule ^([^/]*)/([0-9])/([^/]*)$ $1?$2,$3
RewriteRule ^([^/]*)/([0-9])$ $1?$2

This rewrites all urls of the form
file.php/N/X1/X2/X3/X4/.../Xk to
file.php?N,X1,X2,X3,X4,...,Xk
where N is a number and X1,X2,...,Xk are any string not including a slash ('/').

It works for me, but I'm not sure why! ;) My initial try was with some [N] flags on the first rule, but that doesn't seem to be needed...

f
Re: Mod_Rewrite Hack
December 28, 2004 02:12PM
my Mod_Rewrite Hack
RewriteEngine on
RewriteRule ([^/]*),([^/]*).html$ read.php?$1,$2
RewriteRule ([^/]*),([^/]*),([^/]*).html#([^/]*)$ read.php?$1,$2,$3#$4
RewriteRule ([^/]*),([^/]*),([^/]*),([^/]*).html#([^/]*)$ read.php?$1,$2,$3,$4#$5
RewriteRule sub_([^/]*).html$ index.php?$1
RewriteRule list_([^/]*).html$ list.php?$1
RewriteRule post_([^/]*).html$ post.php?$1

i think maybe the google robot will find the *.html docs more easily than *.php?**
Sorry, only registered users may post in this forum.

Click here to login