All,<br /><br />Instead of creating a bunch of subdirectories, I'd like to be able to rewrite the URL using PHP or some other scripting language.<br /><br />For Example:<br />User enters: <a href="http://www.domainname.com/subdir" target="_blank">http://www.domainname.com/subdir</a><br /><br />I'd like to strip off the subdir characters, look up a matching record in a mysql database, and then redirect the user to <a href="http://www.domainame.com/display/index.php?record=77" target="_blank">http://www.domainame.com/display/index.php?record=77</a> where record 77 is the record id of the subdir matched via the database.<br /><br />Not sure if that makes much sense or not.<br /><br />My first thought is using a custom 404 error message to parse this out. Can i make the 404 error message a PHP script? or must it be a .shtml script as that's showing as the default in the control panel.<br /><br />Any other suggestions?<br /><br />ostrich99<!--content-->
I guess I should clarify too.<br /><br />If I can make the custom error file a PHP file, then I my php skills are probably sufficient. If not, then I'll need some guidance from the group here on how to do this.<br /><br />Ostrich99<!--content-->
Normally you use the mod_rewrte module of the server by adding rules and statements to your .htaccess file.<br /><br />Here is a link to a <a href="http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html" target="_blank">url rewriting tutorial</a> that may help.<!--content-->
Bruce,<br /><br />Thanks for the link. I think this might get me to where I need to be.<br /><br />If I understand the tutorial write, I think I could just rewrite the URL to pass the subdir they used to another PHP script which does the database access,etc. <br /><br />Time to refresh myself on regular expressions. Too many years of windows programing. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><br /><br />Ostrich99<!--content-->
Not sure, I am a noob when using rewrites in the .htaccess file but I am sure some of our other members that know how to do will chime in. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/wink.gif" style="vertical-align:middle" emoid="" border="0" alt="wink.gif" /><!--content-->
You can use PHP on a 404 file. You just want to add a line to your .htaccess page that says<br /><br />ErrorDocument 404 /yourpage.php<br /><br />[Edited out the .htaccess stuff because I reread the post and I don't think I was answering what it needed to do.]<!--content-->
ostrich99, if you can, make it a "subdirectory"... ok let me explain this better: instead of making it work with <!-- w --><a class="postlink" href="http://www.domain.com/subdir">www.domain.com/subdir</a><!-- w --> make it work with <!-- w --><a class="postlink" href="http://www.domain.com/sub/dir">www.domain.com/sub/dir</a><!-- w -->. This way you can create a rewrite rule that redirects only those "special" links and leaves all the rest alone, while creating a redirect rule for <!-- w --><a class="postlink" href="http://www.domain.com/subdir">www.domain.com/subdir</a><!-- w --> would have to catch every link going to your website.<!--content-->
All,<br /><br />Well I got this sorta working using a custom php error page for a 404. <br /><br />Big issue though is that by default, IE will not show custom error pages. There is a setting in IE called "Show Friendly HTTP error messages" and it just shows a generic cannot be found message.<br /><br />Really sucks as this script I wrote works really well, and works fine in Firefox, etc.<br /><br />SO, it looks like I have to go the .htaccess route. <br /><br />Anyone have any idea of I'll have similar issues with that method?<br /><br />Ostrich99<!--content-->
.htaccess will work fine, I use mine for that. IE wont show the other one most likely because the file size it too small.<!--content-->
I guess I should clarify too.<br /><br />If I can make the custom error file a PHP file, then I my php skills are probably sufficient. If not, then I'll need some guidance from the group here on how to do this.<br /><br />Ostrich99<!--content-->
Normally you use the mod_rewrte module of the server by adding rules and statements to your .htaccess file.<br /><br />Here is a link to a <a href="http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html" target="_blank">url rewriting tutorial</a> that may help.<!--content-->
Bruce,<br /><br />Thanks for the link. I think this might get me to where I need to be.<br /><br />If I understand the tutorial write, I think I could just rewrite the URL to pass the subdir they used to another PHP script which does the database access,etc. <br /><br />Time to refresh myself on regular expressions. Too many years of windows programing. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><br /><br />Ostrich99<!--content-->
Not sure, I am a noob when using rewrites in the .htaccess file but I am sure some of our other members that know how to do will chime in. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/wink.gif" style="vertical-align:middle" emoid="" border="0" alt="wink.gif" /><!--content-->
You can use PHP on a 404 file. You just want to add a line to your .htaccess page that says<br /><br />ErrorDocument 404 /yourpage.php<br /><br />[Edited out the .htaccess stuff because I reread the post and I don't think I was answering what it needed to do.]<!--content-->
ostrich99, if you can, make it a "subdirectory"... ok let me explain this better: instead of making it work with <!-- w --><a class="postlink" href="http://www.domain.com/subdir">www.domain.com/subdir</a><!-- w --> make it work with <!-- w --><a class="postlink" href="http://www.domain.com/sub/dir">www.domain.com/sub/dir</a><!-- w -->. This way you can create a rewrite rule that redirects only those "special" links and leaves all the rest alone, while creating a redirect rule for <!-- w --><a class="postlink" href="http://www.domain.com/subdir">www.domain.com/subdir</a><!-- w --> would have to catch every link going to your website.<!--content-->
All,<br /><br />Well I got this sorta working using a custom php error page for a 404. <br /><br />Big issue though is that by default, IE will not show custom error pages. There is a setting in IE called "Show Friendly HTTP error messages" and it just shows a generic cannot be found message.<br /><br />Really sucks as this script I wrote works really well, and works fine in Firefox, etc.<br /><br />SO, it looks like I have to go the .htaccess route. <br /><br />Anyone have any idea of I'll have similar issues with that method?<br /><br />Ostrich99<!--content-->
.htaccess will work fine, I use mine for that. IE wont show the other one most likely because the file size it too small.<!--content-->