Edit #2: i disabled my 404 page and the default not found page says that it’s looking for a url with .php after it:
“The requested URL /events/2012.php was not found on this server”
So now i believe it’s looking for an actual file, when it doesn’t exist. anyone??
Edit #1: looks like the looping redirect is fixed, but I still can’t figure out why the rewrites aren’t working for the events page. /events/ works just fine, but /events/2012/title-id/ goes to a 404. /breweries/ and arizona-breweries/brewery-name/ works also so i’m not sure what i’m missing.
I’m trying to add a new directory structure with my events.php page. events/2012/…
I have another directory structure under breweries.php that works just fine.
When i try to load an event sitename.com/events/2012/title-of-event-3/ it redirect loops and says “too many redirects” and the url looks like this:
sitename.com/events/2012/title-of-event-3.php.php.php.php.php.php.php.php.php.php.php/
I figure 6 hours of searching for an answer were enough. Any and all help appreciated!
(and no i don’t have sitename.com in my real htaccess file)
My htaccess file:
Options +FollowSymLinks -Multiviews
RewriteEngine on
RewriteBase /
#remove php file extension
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteCond %{REQUEST_URI} !^/blog/
RewriteRule ^(.*)/$ $1.php [QSA,L]
#clean urls
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^events/([0-9]+)/(.*)-([0-9]+)/$ events.php?year=$1&title=$2&id=$3 [R,NC,QSA]
RewriteRule ^(.*)-breweries/$ breweries.php?loc=$1 [NC,QSA]
RewriteRule ^(.*)-breweries/(.*)/$ breweries.php?loc=$1&brewery=$2 [NC,QSA,L]
#Force trailing slash after url
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_URI} !example.php
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.sitename.com/$1/ [L,R=301]
#force www
RewriteCond %{HTTP_HOST} !^www.sitename.com$
RewriteRule ^(.*)$ http://www.sitename.com/$1 [R=301,L]
I solved it. I had to move the section that removed the .php extension below the url rewrite section (just above the force www part) and it worked. apparently the breweries section had been in the right place at one time so it continued to work, but when I tried to add a new rewrite it wouldn’t work properly.