Hi, I have this code and I like to transform the final url. The url result of this code for now is: http://www.xxxx.com/index.php?q=west coast customs Code (markup): And I like to transform in http://www.xxxx.com/file_west+coast+customs.html Code (markup): Is this posssible? Thank you for you attention. <?php #DATABASE TAGS $db_host = "....."; $db_user = "....."; $db_pass = "...."; $db_name = "......"; mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error()); mysql_select_db($db_name); function tag_info() { $result = mysql_query("SELECT * FROM Web GROUP BY tags ORDER BY Rand() DESC"); while($row = mysql_fetch_array($result)) { $arr[$row['tags']] = $row['count']; } //ksort($arr); return $arr; } function tag_cloud() { $min_size = 11; $max_size = 25; # GET THE SMALLEST AND LARGET COUNT NUMBERS $sql = mysql_query("SELECT MIN(count),MAX(count) FROM Web"); list($minimum_count,$maximum_count) = mysql_fetch_row($sql); $spread = $maximum_count - $minimum_count; if($spread == 0) { $spread = 1; } $cloud_html = ''; $cloud_tags = array(); $step = ($max_size - $min_size)/($spread); # GRAB THE DATA FROM MySQL $sql = mysql_query("SELECT tags,count,Url FROM Web GROUP BY tags ORDER BY Rand() DESC LIMIT 55"); # USING mysql_fetch_row SO WE CAN USE list() while(list($tag,$count,$url) = mysql_fetch_row($sql)) { $size = $min_size + ($count - $minimum_count) * $step; // $size = ($max_size + $min_size)/$spread; $cloud_tags[] = '<a style="font-size: '. floor($size) . 'px' . '" class="tag_cloud" href="index.php?q=' . $url . '" class="tag_cloud" href="' . $url . '" title="\'' . $tag . '\' returned a count of ' . $count . '">' . html_entity_decode(stripslashes($tag)) . '</a>'; } $cloud_html = join("|", $cloud_tags) . ""; return $cloud_html; } ?> <?php print tag_cloud(); ?> Code (markup):
Here are the .htaccess code for your problem: ReweiteRule ^file_([a-zA-Z0-9_-]).html$ index.php?q=$1 [NC,L] You will get query string on get variable by accessing the URL. Hope this helps Avinash - Xpertdev
Sorry typo mistake, replace with this: RewriteRule ^file_([a-zA-Z0-9_-]).html$ index.php?q=$1 [NC,L] Hope this helps...
Aren't you looking for this? $url = 'http://www.xxxx.com/index.php?q=west coast customs'; echo urlencode($url); //result: http%3A%2F%2Fwww.xxxx.com%2Findex.php%3Fq%3Dwest+coast+customs Code (markup):
RewriteRule ^file_([a-zA-Z0-9_-]).html$ index.php?q=$1 [NC,L] Code (markup): Already try but disen't work Already find on net some htaccess files and dosen't work. I thik the problem is the php. My test site is under http://www.futpt.com
You need to tidy up the spaces replace with this code while(list($tag,$count,str_replace(" ",'+',$url)) = mysql_fetch_row($sql)) { PHP: Then you can run a simple .htacces code Options +FollowSymLinks RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule (.[^/]*) /index.php?q=$1 [NC,L] Code (markup): so this '/west+coast+customs' is the same as this '/index.php?q=west+coast+customs' you can add .html if you wish Also I'm not sure why you have this line: . '" class="tag_cloud" href="index.php?q=' . $url PHP: I dont think you need that.
Already replace this line while(list($tag,$count,str_replace(" ",'+',$url)) = mysql_fetch_row($sql)) { Code (markup): But now gives me an error on line 71 (this line) "Fatal error: Can't use function return value in write context in public_html/tags.php on line 71 while(list($tag,$count,str_replace(" ",'+',$url)) = mysql_fetch_row($sql)) { Code (markup):
Try inserting the str_replace() function here.... . '" class="tag_cloud" href="' . str_replace(" ",'+',$url) PHP:
You are the best... Now I have http://www.xxxxxx.com/west+coast+customs If possible I like to have like thishttp://www.xxxxxx.com/west+coast+customs.html But when I try to put html like this, gives me a error . '" class="tag_cloud" href="' . str_replace(" ",'+',$tag, '.html') Code (markup):
Hi, I transform the string like this, . '" class="tag_cloud" href="' . str_replace(" ",'+',$tag) .'.html' Code (markup): Now I have west+coast+customs.html in url. The only problem is I have "west coast customs.html" in url and search box. Any chance to remove this entry "html" of the the search box? maybe in htaccess? Thank you for your help
Try the following, its not tested though, add these two lines to the .htaccess file and remove the .html bit from your line of code above RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.php?q=([^&]+)\ HTTP/ RewriteRule ^index\.php$ /%1\.html? [R=301,L] Code (markup):
..and you added the two lines to the htaccess file ? Options +FollowSymLinks RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule (.[^/]*) /index.php?q=$1 [NC,L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.php?q=([^&]+)\ HTTP/ RewriteRule ^index\.php$ /%1\.html? [R=301,L] Code (markup):
..and you added the two lines to the htaccess file ? try this one Options +FollowSymLinks RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule (.[^/]*) /index.php?q=$1 [L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.php?q=([^&]+)\ HTTP/ RewriteRule ^index\.php$ /%1\.html? [R=301,L] Code (markup):
I have removed in this line the "html" . '" class="tag_cloud" href="'. str_replace(" ",'+',$tag) Code (markup): I have My htaccess like that Options +FollowSymLinks RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule (.[^/]*) /index.php?q=$1 [L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.php?q=([^&]+)\ HTTP/ RewriteRule ^index\.php$ /%1\.html? [R=301,L] Code (markup): and the result is "west+coast+customs"
Hmm sorry I'm not that well up on my htaccess... one last try, if this one doesnt work, start a new thread with a regards to the htaccess code. The code below should take west+coast+customs" and redirect it to west+coast+customs.html" copy it as one piece, no line breaks Options +FollowSymLinks RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.[^/]*) /index.php?q=$1 [L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.php?q=(.[^/]*)\ HTTP/ RewriteRule ^index\.php$ /%1\.html? [R=301,L] Code (markup):