XGCommander Posted March 28, 2010 Share Posted March 28, 2010 http://www.explicitgamer.com/dev/article/final-fantasy-xiii-review-2 (rewritten URL) http://www.explicitgamer.com/dev/article.php?p=4668 (actual URL) Mod Rewrite Rules: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /dev/article/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /dev/article.php [L] </IfModule> I use the following code in article.php to figure out what article is being pulled: $uri = str_replace("/", "", substr($_SERVER["REQUEST_URI"], 13)); $xg_article = getAllArticleInfoByName($uri); And if it matters, pages are cached, but that shouldn't matter because both the actual and rewritten urls are cached (separately). If you goto the actual url the share tools (digg, reddit, facebook, twitter etc) work fine. If you use the rewritten url none of them work. For some reason they aren't able to connect to the page properly to grab info (or verify the page even exists) through the rewritten url. I'm not really sure what is wrong, but it is kind of irritating that I can't figure out a solution. I'm not too familiar with mod_rewrite so I was hoping someone could help me fix it or direct me to some resources that might be able to help me out. Thanx in advance, Commander Quote Link to comment Share on other sites More sharing options...
cags Posted March 28, 2010 Share Posted March 28, 2010 My first suggestion would be to change it so that you don't have to manipulate REQUEST_URI. <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /dev/article/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^dev/article/([a-zA-Z0-9-]+)/?$ /dev/article.php?name=$1 [L] </IfModule> Then you can use... $xg_article = getAllArticleInfoByName($_GET['name']); Not convinced that will solve your problem, but I'm not sure I entirely understand what the issue is. Quote Link to comment Share on other sites More sharing options...
XGCommander Posted March 28, 2010 Author Share Posted March 28, 2010 That actually didn't work. When I setup the rewrite like that I get: Not Found The requested URL /dev/article/final-fantasy-xiii-review-2/ was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. The problem is that the rewritten URL doesn't work outside of the website. Like if you goto the rewritten URL itself, it works fine, but if you try to submit the URL to something like DIGG, Facebook, or Reddit, their scripts can't find the url so the webpage can't be submitted. http://digg.com/submit/ If you go there, and type in http://www.explicitgamer.com/dev/article/final-fantasy-xiii-review-2 as the article url, it gives an error: This link does not appear to be a working link. Please check the URL and try again. The only thing I can think of is that the mod_rewrite that I currently have setup is actually doing a redirect, not a rewrite. That is the only reason that I can think of that this would be happening. Quote Link to comment Share on other sites More sharing options...
XGCommander Posted March 28, 2010 Author Share Posted March 28, 2010 Incidentally I found out what does work (in a similar fashion to what you were suggesting) and it fixed the problem as well. <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /dev/article/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule article/([a-zA-Z0-9-]+) /dev/article.php?name=$1 [L] </IfModule> All I needed was a push in the right direction. Thank You 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.