SagaLore Posted September 5, 2003 Share Posted September 5, 2003 I\'m using a simple CMS that references content with ?id=27. I know that Google will spider some dynamic links but to be on the safe side I want to try and make that static. I have created an .htaccess file with: <FilesMatch \"^id$\"> ForceType application/x-httpd-php </FilesMatch> And then another file \"id\" with: <?php $idpath = explode(\"/\",$_SERVER[\'PATH_INFO\']); $newid = intval($idpath[1]); include(\"http://www.mysite.com/?id=$newid\"); ?> What this does it turn: http://www.mysite.com/?id=27 into: http://www.mysite.com/id/27 Two dilemmas: I don\'t want to have to use an absolute path in the id file because this feature is going to be made available to other users of the CMS I\'m using. When you use the static path, relative links in the html that is included are broken. This is because they think they are in another subdirectory when in fact it\'s just smoke and mirrors. So instead of rewriting all my html with absolute paths or doing some other hack, I would like to accomplish this: http://www.mysite.com/id27 That way the relative links work okay. I was looking at Apache core directives and came up with something like: <Location ~ \"/id*\"> //some type of parsing here </Location> But I\'m rather new to both php and .htaccess so for now this is getting the best of me. I know what I want to do logically but don\'t know what to do syntactically. Ideas? Quote Link to comment https://forums.phpfreaks.com/topic/988-changing-dynamic-urls-into-static-urls/ Share on other sites More sharing options...
catman Posted September 7, 2003 Share Posted September 7, 2003 use mod_rewrite tut @ http://www.phpfreaks.com/tutorials/23/0.php Quote Link to comment https://forums.phpfreaks.com/topic/988-changing-dynamic-urls-into-static-urls/#findComment-3353 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.