I have created a .htaccess file so I can use some SEO friendly and pretty looking URLs.
I'm wanting to convert:
http://domain.com/page.php?id=200&name=this-is-a-title
To:
http://domain.com/200/this-is-a-title
When I go to the latter URL, it does work but images, css, js etc do not show up. After some Googling I found a few ways on how to ignore paths to files that don't exist and ignoring specific directories. However, whenever I add these rules/conditions the URL rewrite no longer works and I just get a 404 error.
Here is my .htaccess file:
# Turn rewriting on
RewriteEngine On
# Allow any files or directories that exist to be displayed directly
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(inc|css|img|js)($|/) - [L]
#RewriteCond %{REQUEST_URI} "/css/" [OR]
#RewriteCond %{REQUEST_URI} "/img/"
#RewriteCond %{REQUEST_URI} !^/css
# Set rewrite rule
RewriteRule ^([0-9]+)/([^.]+)$ page.php?id=$1&name=$2
As you can see where the commented out lines are, I've tried a few rules to ignore the css/img/js folders, but none work.
Does anyone have any ideas why this might be happening?
EDIT:
Just for some more info, when I right-click and view image info on where an image should be, it's saying its path is 200/img/image.jpg and when I change the image's src to ../img/image,jpg it works, however, I can't really do this as I have some PHP include files that I can't edit because they are used in all my other pages on the site as well, so I can't really go and change the image src in them without duplicating the php file, which would seem silly having two of them