Lets say I have a site that has one page that handles all requests (index.php)
Now, I want tidy URL’s, so I can use .htaccess to redirect to valid URL’s –
part 1 – re-directing all requests to index page where the url string is “exploded” into an array for parsing:
RewriteCond $1 !^(index\.php|robots|files|blog|[0-9]+$)
RewriteRule ^(.*)$ index.php?page=$1 [L]
part 2 – http://example.com/123456:
RewriteRule ^([0-9]+)$ index.php?user=$1 [L]
part 3 – http://example.com/blog/blog_title.html:
RewriteRule ^blog/([a-z0-9-_]+)\.html$ index.php?blog=$1 [L]
RewriteRule ^blog/. /blog/ [R]
Obviously here, I am redirecting the blog post to index.php with the blog variable being the part before “.html” (blog_title), along with any non-compliant URL’s being forwarded to the /blog/ directory.
The problem I have is that I need to then re-direct the URL to “index.php?page=blog” while keeping the address bar displaying http://example.com/blog/
any help would be appreciated!
Even though you found the solution yourself, I thought you might be interested in an alternative way to solve this. This is where I came up with 🙂
Maybe you could even combine the two conditions into
RewriteCond $1 !^(index\.php|robots|files|blog/.|[0-9]+$), but I not sure about the priority of the logical-or (i.e.|).