.htaccess rewrite with sub directories not working

.htaccess, php

Solution

First thing is to have your .htaccess rules like this:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

## If the request is for a valid directory
RewriteCond %{REQUEST_FILENAME} -d [OR]
## If the request is for a valid file
RewriteCond %{REQUEST_FILENAME} -f [OR]
## If the request is for a valid link
RewriteCond %{REQUEST_FILENAME} -l
## don't do anything
RewriteRule ^ - [L]

RewriteRule ^([^/]+)/([^/]+)/?$ index.php/?node=$1&id=$2 [L,QSA]

RewriteRule ^([^/]+)/?$ index.php/?node=$1 [L,QSA]

Then make sure to add this line on top of your page between `<head>` and `</head>`:

<base href="http://mysite.com/">

Problem

I want to rewrite my url from: ``` http://mysite.com/index.php?node=home&photoID=10 ``` to: ``` http://mysite.com/home/10 ``` Currently, for just ``` http://mysite.com/home ``` I use ``` RewriteRule ^([^/]*)$ index.php/?node=$1 [L] ``` however when I try to use ``` RewriteRule ^([^/]*)/([^/]*)$ index.php/?node=$1&id=$2 [L] ``` it doesn't seem to load my pages correctly, the pages aren't styled or anything. (also, the top of my .htaccess file have: ``` RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d ``` and if I just go to mysite.com/home it shows 404 not found. How would I do this if there is not always going to be a sub page?

Original source