Ok, so I have the following in my htaccess: Options +FollowSymLinksRewriteEngine onRewriteRule ^(.*)/?$ index.php?page=$1 [QSA,L] Code (markup): Now, that works great for site.com/page , but doesnt work for site.com/page/ <-- note the trailing slash. What I want to do is have a trailing slash and if you type the url without the trailing slash you are forced to the trailing slash version (make sense?). This sort of stuff makes no sense to me and I assume (hope) that this something simple that a good coder knows how to fix, simply. Any help is appreciated.
Options +FollowSymLinks RewriteEngine on RewriteRule ^(.*[^/])$ $1/ [R=301] RewriteRule ^(.*)/$ index.php?page=$1 [QSA,L] Code (markup):
Let's see, you might have to escape the slash Options +FollowSymLinks RewriteEngine on RewriteRule ^(.*[^\/])$ $1/ [R=301] RewriteRule ^(.*)\/$ index.php?page=$1 [QSA,L] Code (markup): What error did it give you?
Hi, still didn't work. I am getting this error: Moved Permanently The document has moved here. Additionally, a 400 Bad Request error was encountered while trying to use an ErrorDocument to handle the request. ... if I use trailing slashes or not.
1. What browser are you using to view your site in? 2. Do you have anything else in your .htaccess file? If so, can you post it here?
Hi... there is nothing else in my htaccess. Here is the index.php file, though. If you know of a better way of doing all this, by all means, feel free to let me know. <?php require('/home/mysite/config.php'); if($_GET['page']) { $page = $_GET['page']; $q = mysql_query("SELECT * FROM cms WHERE name = '$page'"); if(mysql_num_rows($q)) { // insert the correct page $page_info = mysql_fetch_array($q); } else { // the requested page is not in the db, default to home $page_info = mysql_fetch_array(mysql_query("SELECT * FROM cms WHERE name = 'home'")); $page = 'home'; } } else { // there's no query string, default to home $page_info = mysql_fetch_array(mysql_query("SELECT * FROM cms WHERE name = 'home'")); $page = 'home'; } ?> <html> <head> <title><?=$page_info['title']?></title> <meta name="keywords" content="<?=$page_info['meta_kwds']?>" /> <meta name="description" content="<?=$page_info['meta_desc']?>" /> </head> <body> <?php include($page . '.inc'); ?> </body> </html> Code (markup):
Options +FollowSymLinks RewriteEngine on RewriteRule ^([^.]+)$ index.php?page=$1 [QSA,L] You can add RewriteRule ^([^.]+)/$ index.php?page=$1 [QSA,L] before the one RewriteRule if you need to.