-3

I have a db with various blog entries stored. I have a generic display page (blog.php) and when a entry is selected, use url variable and GET to display the blog entry, so url will be something like blog.php?entry=xyz

Is there a way to remove the blog.php?entry= so it just displays xyz?

Chetan Paliwal
  • 1,620
  • 2
  • 15
  • 24
wadey
  • 93
  • 3
  • 10
  • Has to be a dupe...Have you tried anything... you know enough to add the tag 'url_rewriting' so what have you attempted? – ficuscr Feb 28 '14 at 21:39
  • @ficuscr just typed url in the tags and it came up and seemed right. Sorry for not understanding as much as others (thought that was the whole point of this site) – wadey Feb 28 '14 at 22:09

1 Answers1

0

Creat a .htaccess file containing the following:

RewriteEngine On
RewriteRule ^entry/([^/]*)$ /blog.php?entry=$1 [L]

Would result in an URL of

/blog/entry/xyz

being redirected to /blog.php?entry=xyz

If you just wanted anything after the / mark redirected to blog.php?entry=xys then this would be the htaccess file:

RewriteEngine On
RewriteRule ^([^/]*)$ /blog.php?entry=$1 [L]
Robert Owen
  • 930
  • 7
  • 12
  • Doesn't seem to work. I click the link to go to blog.php?art=xyz and it still takes me to blog.php?art=xyz. I've put the .htaccess file in the same directory. Any ideas? – wadey Feb 28 '14 at 22:11
  • Sorry maybe I misunderstood your question, but you would rebuild your links to look like /xyz this would then redirect you to blog.php?art=xyz (behind the scenes while keeping the url looking the same) – Robert Owen Feb 28 '14 at 22:38