I have a site that currently has:
- Code: Select all
/dir_one (w/index.php)
/dir_two (w/index.php)
/dir_two/some_page.php?a=x (x is an integer)
/dir_two/other_page.php
Rather than have a ton of pages, I'm moving everything to a db where I store a path and content. So in development, I have one index.php in the root. But I have a page in a subdirectory with good google ranks for certain query string values that I want to handle gracefully/efficiently. So I kept that page in place and use its PHP to redirect to a more friendly URL. While I end up with friendly URLs (e.g. /dir_two/page/item_name), all things go through index.php in the background. So I want
- Code: Select all
/dir_one ==> index.php?page=dir_one
/dir_two ==> index.php?page=dir_two
/dir_two/page_a.php?a=1 ==> index.php?page=dir_two/page/item_name
/dir_two/page_a.php?a=2 ==> index.php?page=dir_two/page/diff_item
... (and so on for page_a.php?a=x)
/dir_two/page_b.php ==> index.php?page=dir_two/page_b
This is what I in /.htaccess on my dev server:
- Code: Select all
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^$ /index.php?p=home
RewriteRule ^([a-z0-9/-]+)$ /index.php?p=$1
/dir_two - by itself - is the problem child. I have the following behavior:
- navigating to "dir_two" sends me to "dir_two/?page=dir_two"
- navigating to "dir_two/" keeps me at "dir_two/" but with a trailing slash unlike every other page.
I've tried adding
- Code: Select all
RewriteCond ^%{REQUEST_URI}/$ -d
RewriteRule .* /index.php?p=dir_two [L]
at the end to trim the problem slash specifically for dir_two, but that doesn't work. I still end up "/dir_two/?page=dir_two" ...
Help (solution or suggestion for better handling this new layout + the page I sort of need to keep in place for a bit) is greatly appreciated!
Best regards -
- fishburn