lovephp Posted June 20, 2015 Share Posted June 20, 2015 Ok so I created this blog and also managed to successfully store the title of the topic as blog_url now how on earth I fetch it on browser to display as www.mysite.com/TOPICID1/2015/06/20/my-topic-for-the-blog.php Help out from here please in a secure way. Regards Quote Link to comment https://forums.phpfreaks.com/topic/296932-how-to-display-seo-friendly-content/ Share on other sites More sharing options...
QuickOldCar Posted June 21, 2015 Share Posted June 21, 2015 Your blog scripts should link to those type urls in a href. If you want to get results such as that particular article would query the database matching the category/dates and or by the pretty_slug such as my-topic-for-the-blog Quote Link to comment https://forums.phpfreaks.com/topic/296932-how-to-display-seo-friendly-content/#findComment-1514507 Share on other sites More sharing options...
lovephp Posted June 23, 2015 Author Share Posted June 23, 2015 (edited) ok i got it wroking on wamp server but now that i try it on my webhost one a subfolder as /blog i am getting 404 page not found error :-( here is the rewrite rule in .htaccess file RewriteEngine On RewriteRule ^blog/([a-zA-Z0-9-/]+)$ article.php?$1 RewriteRule ^blog/([a-zA-Z0-9-/]+)$ article.php?$1 in my root folder i also have another .htaccess file which is as follow RewriteEngine On DirectoryIndex index.php ErrorDocument 404 http://www.site.com ErrorDocument 403 http://www.site.com RewriteCond %{HTTP_HOST} ^site\.com$ [NC] RewriteRule ^(.*)$ http://www.site.com/$1 [R=301,L] <IfModule mod_deflate.c> <FilesMatch "\.(css|x?html?|php)$"> SetOutputFilter DEFLATE </FilesMatch> </IfModule> <IfModule mod_expires.c> ExpiresActive On ExpiresByType text/css A100 ExpiresByType text/html A100 </IfModule> what is wrong here? the url is as following http://www.site.com/blog/ID1/2015/06/22/neque-porro-quisquam-est-qui-dolorem-ipsum-quia-dolor-sit-. and in article.php this is how i am fetching the results <?php session_start(); require_once("dbcontroller.php"); $db_handle = new DBController(); include("log.php"); $url = mysql_real_escape_string($_SERVER['REQUEST_URI']); $url = str_replace('/blog/', '', ucwords($url)); $sql=mysql_query("SELECT id,blog_title,blog_image,blog_youtube,blog_article,created,views FROM article WHERE blog_url='".$url."'"); mysql_query("UPDATE article SET views = views +1 WHERE blog_url ='".$url."'"); $count = mysql_num_rows($sql); $row=mysql_fetch_array($sql); if($count <1){ header("ERROR: 404"); exit(); } ?> Edited June 23, 2015 by lovephp Quote Link to comment https://forums.phpfreaks.com/topic/296932-how-to-display-seo-friendly-content/#findComment-1514718 Share on other sites More sharing options...
lovephp Posted June 23, 2015 Author Share Posted June 23, 2015 ok got it working with the following code # SEO URL Settings RewriteEngine On RewriteBase /blog/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)\?*$ article.php?$1 [L,QSA] but is it ok? Quote Link to comment https://forums.phpfreaks.com/topic/296932-how-to-display-seo-friendly-content/#findComment-1514725 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.