dustinnoe Posted March 26, 2007 Share Posted March 26, 2007 I have the following rule: RewriteRule ^(latest|latest/)$ index.php It works great when I include the trailing slash in the URL. When the trailing slash is absent all of my relative links drop the 'latest' directory and move up one directory. How do I force recognition of a directory when there is no trailing slash? Quote Link to comment Share on other sites More sharing options...
dustinnoe Posted March 28, 2007 Author Share Posted March 28, 2007 OK! I found a solution, directly from Apache, but that same solution creates another problem. Here are the rewrite rules: RewriteBase / RewriteRule ^latest$ latest/ [R] RewriteRule ^latest/?$ index.php RewriteRule ^latest/page(.*).html$ index.php?page=$1 RewriteRule ^user/(.*)$ user/$1/ [R] RewriteRule ^user/(.*)/$ journal.php?user=$1 RewriteRule ^user/(.*)/page([0-9]+).html$ journal.php?user=$1&page=$2 The top set of rewrite rules works great but on the second set when I introduce a variable it adds two trailing slashes instead of one. So if the user enters http://mydomain.com/user/username (with or without the trailing slash) mod_rewrite outputs this http://mydomain.com/user/username// Any ideas? Quote Link to comment Share on other sites More sharing options...
dustinnoe Posted March 28, 2007 Author Share Posted March 28, 2007 Allrighty, I solved my own problem again. After taking a nice break from nearly punching the computer screen out of frustration I realized what had happened. The Regex I was feeding the pattern was matching the forward slash character, duh! So I just specified what the pattern should match. New Rules: RewriteBase /qt/ RewriteRule ^latest$ latest/ [R] RewriteRule ^latest/?$ index.php RewriteRule ^latest/page(0-9]+).html$ index.php?page=$1 RewriteRule ^user/([a-zA-Z0-9_]+)$ user/$1/ [R] RewriteRule ^user/([a-zA-Z0-9_]+)/$ journal.php?user=$1 RewriteRule ^user/([a-zA-Z0-9_]+)/page([0-9]+).html$ journal.php?user=$1&page=$2 Ahh, I feel much better now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.