g1smd

msg:4378778 | 5:47 pm on Oct 24, 2011 (gmt 0) |
You need the [L] flag on every rule and the $ symbol on each RegEx pattern. Your extensionless URLs should not end with a trailing slash. Trailing slash is reserved as the URL for a folder or for the index page in a folder. RewriteRule does not "make" new URLs. It looks at the request made after the link is clicked. Therefore, the first step is to change the URLs in the links on your pages to point to the friendly URLs.
|
username

msg:4378891 | 9:57 pm on Oct 24, 2011 (gmt 0) |
Hi, so I edited the rules, and the first rule on it's own lets me get the two folder variables correctly using: RewriteRule ^([^/]+)/([^/]+)$ index.php?var1=$1&var2=$2 [L] ...gets abc, xyz for the two folders ...however the rule that handles only 1 folder gets index.php as the first variables instead of abc on it's own, and when added to the .htaccess file as a second rule, makes the 2 folders rule retrieve index.php for the first variable also RewriteRule ^([^/]+)$ index.php?var1=$1 [L] ..my .htaccess file as it stands is: Options +FollowSymlinks RewriteEngine on RewriteRule ^([^/]+)/([^/]+)$ index.php?var1=$1&var2=$2 [L] RewriteRule ^([^/]+)$ index.php?var1=$1 [L] Do I need an OR condition?
|
g1smd

msg:4378906 | 11:05 pm on Oct 24, 2011 (gmt 0) |
Have you got any other RewriteRules or any redirects anywhere in this site?
|
username

msg:4378942 | 1:51 am on Oct 25, 2011 (gmt 0) |
At the very top level of the site. This rule addresses the 301 redirect. RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] Interesting my rule is for the first level folder and everything down: i.e. http:www.test.com/folder/ the .htaccesss exists in here, and should only work for this folder. It's weird because when I test with the non www version it puts $url as the second folder. Any ideas?
|
lucy24

msg:4378981 | 3:44 am on Oct 25, 2011 (gmt 0) |
Y'know, I kinda suspect this is a php problem rather than an htaccess one. You might try first creating some query strings with literal text, like "foo&bar&widget", and feed it into your php code to see if it's returning what it's supposed to. Otherwise you're potentially trying to juggle two problems at once. PHP is less dangerous than htaccess, so get that fine-tuned first.
|
g1smd

msg:4379034 | 6:58 am on Oct 25, 2011 (gmt 0) |
Your non-www to www rule is missing escaping of literal periods. It also doesn't redirect www requests with appended port number. See recent threads for better code. This particular sub-topic comes up almost every day. I would have all the rules in one .htaccess file in the root so that you can control the order they are parsed. Make sure you are not using Redirect or RedirectMatch anywhere within the site as that will likely have unintended consequences.
|
|