Forum Moderators: phranque
This is the url now.
file.php?name=Zone_Database&file=zone_detail&zoneid=$var
which I would like to rewrite to
Zone_Database-Zone-Name-$var.html
this is my attempt to rewrite it
?name=Zone_Database&file=zone_detail&zoneid=([A-Z][a-z][a-z]*)
but that does not work.
Any suggestions on how to rewrite multie string variablse?
I beleive all I need to do is change this
([A-Z][a-z][a-z]*)
to the correct coding.
Thanks all
Cheers
Forgive me if this sounds at all arrogant but, I am using phpnuke (from what I have heard this may be frowned upon.) Now with phpnuke I have looked through the HTACCESS and to rewrite urls it is using code such as this
RewriteRule ^Item_Database-([1-9][0-9][0-9]*).html modules.php?name=Item_Database&file=item_page&id=$1
That code, along with a duplicate in the urlin array in header.php and a urlout array which looks like this
"Item_Database-\\1.html"
Changes a url such as this
modules.php?name=Item_Database&file=item_page&id=296
into this
"Item_Database-296.html"
lol Do not ask me how this works, I do not know. But it does work, I have almost my entire site rewritten but, for some reason these multiple word variables come oout different.
If I want something like this to be the output
"Zone_Database-Zone-Name-$var.html"
It works fine for 1 word variables but more than one word is output like this
"Zone_Database-Zone-Name-$word1.html$word2$word3$word4"
Which obviously does not work.
If I am just rambling and none of this makes sense I am sorry but this is my problem and I am hoping that someone knows what I can do.
Thank you very much.
Dylan Kingsberry
Cheers.
RewriteRule ^Item_Database-([1-9][0-9][0-9]*).html modules.php?name=Item_Database&file=item_page&id=$1
RewriteRule ^Item_Database-([1-9][0-9]{1,})\.html$ modules.php?name=Item_Database&file=item_page&id=$1
This code actually changes a url such as "Item_Database-296.html" to "modules.php?name=Item_Database&file=item_page&id=296", so knowing the "direction" of the rewrite may help you to understand the process. The true URLs seen by users and search robots are static, and those are rewritten to dynamic form to call your script. WebmasterWorld uses a similar approach.
It sounds like there's probably some code interaction going on that is messing things up.
There are links to mod_rewrite and regular expressions resources in our Apache Forum charter that may be of use to you.
Jim
with single words if I had this [A-Z] it would only put the first letter. So like this.
S.htmlite
when I added this [A-Za-z]
I would get this.
Site.html
which is right, is there something equivalent to this for words.
I am very sorry but I have no idea what i am doing and this forum is my only chance for getting this resolved.
Thank you
Cheers
I am very sorry but I have no idea what i am doing
By the way in think you are on the wrong track (or you just misled me too)
mod_rewrite processes the incoming urls only; so only processes the requests sent to the webserver. For example if I want to do what you're asking for (I think ;-) then I'd do something like this in my htaccess file:
RewriteEngine on
RewriteRule ^Zone_Database-Zone-Name-(.+)\.html?$ file.php?name=Zone_Database&file=zone_detail&zoneid=$1 [L]
http://www.domain.com/Zone_Database-Zone-Name-Anything goes here.html url, it will be internally interpreted as http://www.domain.com/file.php?name=Zone_Database&file=zone_detail&zoneid=Anything goes here. This is only for the incoming requests. But, if you have links like this
http://www.domain.com/file.php?name=Zone_Database&file=zone_detail&zoneid=Anything goes here Hope this helps
Now is I have to strings
whistle-1
whistle 1
Like so this will output
whistle-1.html
whistle.html1
So now I need it to take spaces as well, so if the word seperator is either a - or a space it will take it.
I will look over the forum charter but, please if you know please post.
Thank you
Cheers.
If those spaces are %-encoded (check your server log to see), then things get a bit more complex. In that case, you'll need ([A-Za-z]([A-Za-z-]¦\%20)+)
Note that in the pattern above, you'll have to edit the "¦" character, and change it to a solid vertical pipe -- posting pipes on this board changes them for some reason, and you have to edit them before use.
Jim