Web Hosting Talk







View Full Version : Mod_Rewrite Changes


Sticks
10-23-2004, 04:41 AM
Hi ,
I need some help I hope someone would tell me how to do this.

I want to rewrite this index.php?cat=Webmaster Resources to index_Webmaster-Resources.html
Or any .html output without spacing .

I actually can do mod_rewrite by myself but the "Webmaster Resources" part is killing me because it's not like index.php?cat=3 etc. It's completely text and caps ara important.
Best Regards,
Umut

tiamak
10-23-2004, 10:18 PM
so you want link like http://myweb/index_Webmaster-Resources.html

??
if yes then write rewrite rule
like for example


RewriteRule ^(index_Webmaster-Resources.html)(.*)$ /path/to/some/script.php [L]


and then in file to which mod_rewrite will redirect query
add simple code like

if (strpos($_SERVER['REQUEST_URI'], 'Webmaster')) {
$cat = str_replace('index_', '', str_replace('-', ' ', $_SERVER['REQUEST_URI']));
}


and thats all :)

nickn
10-23-2004, 10:42 PM
What's the exact URL? Does the URL really have a space in it?

tiamak
10-23-2004, 11:27 PM
%20 ? or + ? :)

so url would be like http://lalala/?cat=Webmaster%20resource

but from server side in php, $_GET[cat] would be the same as "Webmaster resource" not "Webmaster%20resource"
so if he currently use http://lalala/?cat=Webmaster%20resource
and he to use some mod rewrite rule instead but want his script to work correctly then my suggestion is ok :) at least works for me

or maybe he want to do something else, then sorry that i understand it in wrong way but my english sux :)