Hello all,
I have never used mod_rewrite before but I have been advised by a marketing company my workplace uses tthat I need to rewrite my urls which appear as so:
mywebsite/insurance-news/news.php?id=800464237&title=building_stocks_plummet
into something more like:
mywebsite/insurance-news/id/800464237/title/building_stocks_plummet/
or
mywebsite/insurance-news/id/800464237/title/building_stocks_plummet.html
I have been trying for over 9 hours now to figure this out and have followed all the tutorials I can find with no luck, mod_rewrite is functional on my server as I created a test redirect as exlpained on one of the tutorials and it worked perfectly so I am not sure what I am doing wrong.
This is the link that brings the page up which creates the “non-friendly” urls I am trying to re-write
<a href=“news.php?id=<?php echo $row_BusinessInsuranceNews[‘newsArticleID’]; ?>&title=<?php echo str_replace(array(’ ‘, ’ ‘), ‘_’, preg_replace(’/[^a-zA-Z0-9 s]/’, ‘’,$row_BusinessInsuranceNews[‘htmlTitle’])); ?>”>more</a>
However, after numerous attempts at different rules when I click on it all I get is my dynamic URL:
mywebsite/insurance-news/news.php?id=800464237&title=building_stocks_plummet
These are the rules I have tried so far: Note: my .htaccess file is located in the correct directory and is headed up with:
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^news/?([0-9]+)/([a-zA-Z_])/$ /news.php?id=$1&title=$2 [L]
RewriteRule ^news/([^/]+)/([^/]+)/?$ /news.php?id=$1&title=$2&size=$3 [L]
RewriteRule ^news/(.)/(.)/$ /insurance-news/news.php?id=$1&title=$2
RewriteRule news/id/(.)/title/(.)/ news.php?id=$1&title=$2
RewriteRule news/id/(.)/title/(.) news.php?id=$1&title=$2
I have tried all of the above and many variations in between - Can anyone help me out? Any advice would be greatly appreciated