EvanAgee Posted November 1, 2008 Share Posted November 1, 2008 Okay, so both of the servers in question were runnig Apache/2.0.52 (CentOS). However, on one server my htaccess mod_rewrite syntax is working perfectly and on the other it's not working at all! Below is the syntax. RewriteEngine on RewriteRule ^print/$ /lib/cjprinterfriendlyv2/printpage.php RewriteRule ^make_offer/(\d+) /?action=make_offer&p=$1 [L] RewriteRule ^blog(/|)$ /?action=blog [L] RewriteRule ^blog/(.+)$ /?p=$1 [L] RewriteRule ^tags/(.+)$ /?tag=$1 [QSA,L] RewriteRule ^asset/(.+)/(\d+)(|/)$ /?asset=$1&id=$2 [L] RewriteRule ^video/(\d+)(|/)$ /?asset=video&id=$1 [L] RewriteRule ^asset/video/(.+)(\.php|\.html|\.htm)$ /?asset=video&file_name=$1 [L] RewriteRule ^video/(.+)(\.php|\.html|\.htm)$ /?asset=video&file_name=$1 [L] RewriteRule ^tags/$ /?tag=INDEX [L] RewriteRule ^presearch/$ /?action=presearch [QSA,L] RewriteRule ^search/(.*)/(|pages|images|videos)$ /?action=search&s=$1&t=$2 [L] RewriteRule ^sitemap/$ /?action=sitemap [L] RewriteRule ^sitemap/(image|video)(&p=(\d+)|)$ /?action=sitemap&m=$1&p=$3 [L] RewriteRule ^ecommerce-videos-movies/$ /?action=sitemap&m=video [L] RewriteRule ^ecommerce-images-photos/$ /?action=sitemap&m=image [L] RewriteRule ^email_this_page/(\d+)(|/)$ /?action=email_page&pid=$1 [L] RewriteRule ^email_this_page/asset/(\d+)(|/)$ /?action=email_page&&is_asset=true&aid=$1 [L] RewriteCond %{REQUEST_URI} !^/lib/ RewriteCond %{REQUEST_URI} !^/admin/ RewriteRule ^(.+)(\.php|\.html|\.htm|\/)$ /?p=$1$2 [QSA,L] For the newer server that's not doing what I expect my URLS http://www.domain.com/dynamic_page_title/ aren't working correctly. On my older server it worked perfectly. Any ideas? Quote Link to comment Share on other sites More sharing options...
corbin Posted November 1, 2008 Share Posted November 1, 2008 Rewrites probably aren't enabled on one of the servers. Quote Link to comment Share on other sites More sharing options...
EvanAgee Posted November 1, 2008 Author Share Posted November 1, 2008 I don't believe that's it because some of the RewriteRules higher on the list work correctly. Quote Link to comment Share on other sites More sharing options...
corbin Posted November 2, 2008 Share Posted November 2, 2008 I don't see any rules that would match dynamic_page_title/ Quote Link to comment Share on other sites More sharing options...
EvanAgee Posted November 2, 2008 Author Share Posted November 2, 2008 This one worked on my old server: RewriteRule ^(.+)(\.php|\.html|\.htm|\/)$ /?p=$1$2 [QSA,L] Quote Link to comment Share on other sites More sharing options...
corbin Posted November 2, 2008 Share Posted November 2, 2008 dynamic_page_title doesn't end in php html or html x.x. Quote Link to comment Share on other sites More sharing options...
EvanAgee Posted November 2, 2008 Author Share Posted November 2, 2008 But it does end in / which is also part of that regexp. Quote Link to comment Share on other sites More sharing options...
corbin Posted November 2, 2008 Share Posted November 2, 2008 Oh my bad. Misread that. Didn't see that last pipe there. Do you get a 500 error or a 404 error? Quote Link to comment Share on other sites More sharing options...
EvanAgee Posted November 2, 2008 Author Share Posted November 2, 2008 Originally I was getting a 500 error because my php file that controls all of the various URLs is index.php, so I was getting a too many redirects error. I fixed that problem and now I'm just getting a 404 error. Again, this was working fine on my last server with the same host. Quote Link to comment Share on other sites More sharing options...
trq Posted November 2, 2008 Share Posted November 2, 2008 Have you tried setting up RewriteLog and RewriteLogLevel to see if you can get mod_rewrite to report errors? Quote Link to comment Share on other sites More sharing options...
EvanAgee Posted November 2, 2008 Author Share Posted November 2, 2008 No I haven't, do you know of a particularly good tutorial to get me started? Quote Link to comment Share on other sites More sharing options...
trq Posted November 2, 2008 Share Posted November 2, 2008 Just add these lines to the top of your .htaccess file. RewriteLog "/path/to/rewrite.log" RewriteLogLevel 5 Apache will need perms to write to /path/to/rewrite.log, you'll also want to remove this once (if) it helps you as it adds allot of overhead to each request. Quote Link to comment Share on other sites More sharing options...
EvanAgee Posted November 2, 2008 Author Share Posted November 2, 2008 I get a "RewriteLog not allowed here " error when I try to place the log file in the same direcotry as my error_log, etc files are. Quote Link to comment Share on other sites More sharing options...
EvanAgee Posted November 2, 2008 Author Share Posted November 2, 2008 SOLVED Just had to add: RewriteCond %{REQUEST_URI} !^/index.php after RewriteCond %{REQUEST_URI} !^/admin/ Thanks everyone, now I can go into Monday with a clean slate and ready to work! Quote Link to comment Share on other sites More sharing options...
corbin Posted November 3, 2008 Share Posted November 3, 2008 Infinite redirects are a pain.... 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.