Abhijit Dutta
Abhijit Dutta

Reputation: 53

How to retreive data from url using SLUG php mysql

I just want to send slug of the blog in href. Code post_url = slug of that blog title

<h3><a href="<?= $base_url ?>blog/<?=$rowposts['post_url']?>">Read</a></h3>

Url will be this - http://localhost/Office/VTPL/Varneli%20HOME_CMS/vareli-home/blog/this-is-my-blog

enter image description here

Here is the .htaccess file screenshot. Please check the selected line

enter image description here

Please help me out... How will I do that...

Upvotes: 0

Views: 202

Answers (1)

Md Jahid Khan Limon
Md Jahid Khan Limon

Reputation: 341

Replace your .htaccess line with this

RewriteRule ^blog/([A-Za-z0-9_-]+)/?$    blog/blog-details.php?post=$1     [L,QSA]

To get URL, PHP code

$full_url = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";

Upvotes: 2

Related Questions