htaccess files have never been a strong point for me unfortunately.
I'll just jump right in:
#Turn RewriteEngine on
Options +FollowSymLinks
RewriteEngine on
#Canonicalize URL
RewriteCond %{HTTP_HOST} !^www\.domain-removed\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/?(.*) http://www.domain-removed.com/$1 [L,R,NE]
#Add Trailing Slash
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
#Clean URLs
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^themes/([a-zA-Z0-9]+)/$ themes/view.php?theme=$1
RewriteRule ^account/([a-zA-Z0-9]+)/$ account/index.php?page=$1
So going to domain.com/themes/theme-name/
and domain.com/themes/view.php?theme=theme-name
works fine and both show the same page/results. However, going to domain.com/account/index.php?page=page
works but going to domain.com/account/page/
doesn't, it just returns a 404 Not Found.
page
variables can be things such as login
, create
, dashboard
and logout
etc. The index.php
in the account directory will process this variable.
It's confusing me as to why it doesn't work as it's the same situation, just under a different directory and a different file name, but both are declared in the rule. Anyone now what I'm doing wrong?
EDIT
I've also tried doing this and defining the pages, like so:
RewriteRule ^account/login/$ account/login.php
RewriteRule ^account/logout/$ account/logout.php
RewriteRule ^account/create/$ account/create.php
RewriteRule ^account/dashboard/$ account/dashboard.php
But still it just returns a 404