-1

I know this question has been asked and answered many times here. I cannot resolve the issue and this represents the 'last resort' for me.
I've tried every solution I've come across on here and I've visited at least 10 websites (even tried .htaccess generators) and I just can't get it right.

I want to rewrite my url to show the query string as a path.

Instead of showing:
tricethebeast.com/post3.php?post_title=Subtly%20Spring
I would like to use:
tricethebeast.com/post3/Subtly-Spring
I'm not terribly concerned with the space in the title. It can be changed to a different character if necessary and I can handle it separately when I display it.

Also, I would like to be able to handle the reverse external request:
tricethebeast.com/post3/Subtly-Spring
And route it to the 'real' location:
tricethebeast.com/post3.php?post_title=Subtly%20Spring

*Edit: I should mention what I mean by doesn't work. I get 500 errors because of some syntax error or the page loads but the url just does not change (incorrect .htaccess).

PSFord
  • 29
  • 1
  • 6
  • `.htaccess` doesn't handle errors well, and will break very easily, you need to do things perfectly to succeed. There are ***Many*** guides to doing what you are aiming to achieve. You shouldn't need to ask a new SO question here. – Martin Jun 19 '16 at 18:08
  • Please read the following Guides: [branded mod rewrite](https://www.branded3.com/blog/htaccess-mod_rewrite-ultimate-guide/) , [Apache URL rewriting Guide](http://httpd.apache.org/docs/2.0/misc/rewriteguide.html) , A very good [Net tuts+ guide](http://code.tutsplus.com/tutorials/an-in-depth-guide-to-mod_rewrite-for-apache--net-6708) , a **HUGE** resource of information [on Ask Apache](http://www.askapache.com/htaccess/modrewrite-tips-tricks.html), [beginners guide from AddedBytes](https://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/), etc etc etc..... – Martin Jun 19 '16 at 18:11
  • Possible duplicate of [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](http://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) – Martin Jun 19 '16 at 18:12

1 Answers1

0

Give this a try:

RewriteEngine On
RewriteRule ^post3/Subtly-Spring$ /post3.php?post_title=Subtly\%20Spring [L]
Joe
  • 4,877
  • 5
  • 30
  • 51
  • I used Subtly Spring as an example. I'm looking to be able to handle dynamic titles. After modifying your answer I have: RewriteEngine On RewriteRule ^post/([\w-]+)$ /post3.php?post_title=$1 [L] – PSFord Jun 19 '16 at 22:12