Not sure what is the problem with my .htaccess file or perhaps I do not understand yet how to use it.
As I understand it:
*i can place in href=" " in <a> tag something like
someMeaningfulStuff/post-about-something-here
*i can have an .htaccess file in the same directory as the php script that is the actual target of the link which can pick up said url (rewriteRule), use a regular expression to extract a portion of it
AND
insert it in the actual url where the resource lives while client has on their browser url addres something like:
http://localhost:8080/adminBlog/post-about-something-here
eventhough it is actually here:
http://localhost:8080/adminBlog/viewPost.php?id=1
Am I wrong? Here is my files thanx in advance!
the url in index.php(root) to http://localhost:8080/adminBlog/viewPost.php?id=1
echo '<h3><a href="/adminBlog/' . $res["postUrl"] . ' " target="_blank" title="link to post" rel="help">' . $res["postTitle"] . '</a></h3>';
where $res['posturl'] is the response from a query to a database which holds a response in the form:
some-title-to-some-blog-post
have wamp/apache config:
LoadModule rewrite_module modules/mod_rewrite.so
AllowOverride All Options Indexes FollowSymLinks MultiViews Order allow,deny allow from all
.htaccess file:
Options FollowSymLinks RewriteEngine on RewriteBase /adminBlog RewriteRule ^/?adminBlog/(.+)$ /viewPost.php?id=$1
5. in http://localhost:8080/adminBlog/viewPost.php
$q = $dbConPDO->prepare('SELECT postId, postTitle, postDesc, postDate, postCont FROM ' .$x. ' WHERE postUrl = :friendlyUrl');
$q->execute(array(':friendlyUrl' => $_GET['id']));
$res = $q->fetch();
6. directory
-c
-wamp
-www
-index.php
-adminBlog //(this dir is within www as index.php is)
-.htaccess //(as above in #3)
-viewpost.php
Solved!
I was mistakenly reasoning that the .htaccess file had to be in the folder of the target php script that was to handle the data while the referrer was in the root folder.
1. Referrer (<a href='' >;, in index.php) in root (/) now reads:
2 .htaccess in root now reads:
Perhaps the RewriteBase is unnecessary as this file is in root dir.
It was as simple as that!
Thanx for the help!