I've been having a hard time getting this to actually work. So I'm using a CMS that through its own administration tools utilizes "pretty urls" so the .htaccess
file that is generated comes pre-supplied with a Rewrite Condition already. Now this works but its only for the CMS generated pages that are extensions of the index.php
. So for example index.php?id=maps
are nicely shown as www.siteurl.com/maps/
instead of www.siteurl.com/index.php?id=maps
.
Now my problem is that I have about 1900+ product pages that are generated from query strings.
So for example I have page urls that look like:
https://www.siteurl.com/item.php?id=0012345&pg=author-title
ideally I want the urls to be:
https://www.siteurl.com/0012345/author-title.html
I've tried a number of mod_rewrite generators to give me the correct syntax, but nothing has worked so far.
Currently in my .htaccess
file is the preexisting language:
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /?([A-Za-z0-9_-]+)/?$ index.php?id=$1 [QSA,L]
I changed it to something like this:
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /?([A-Za-z0-9_-]+)/?$ index.php?id=$1 [QSA]
RewriteRule ^([^/]*)/([^/]*)\.html$ /item.php?id=$1&pg=$2 [QSA,L]
But it doesn't work. I just get a 404
page. Please tell me where I'm wrong. Thanks.