Jump to content

Recommended Posts

Posted

All,

 

Instead of creating a bunch of subdirectories, I'd like to be able to rewrite the URL using PHP or some other scripting language.

 

For Example:

User enters: http://www.domainname.com/subdir

 

I'd like to strip off the subdir characters, look up a matching record in a mysql database, and then redirect the user to http://www.domainame.com/display/index.php?record=77 where record 77 is the record id of the subdir matched via the database.

 

Not sure if that makes much sense or not.

 

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.

 

Any other suggestions?

 

ostrich99

Posted

I guess I should clarify too.

 

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.

 

Ostrich99

Posted

Bruce,

 

Thanks for the link. I think this might get me to where I need to be.

 

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.

 

Time to refresh myself on regular expressions. Too many years of windows programing. :blush:

 

Ostrich99

Posted (edited)

You can use PHP on a 404 file. You just want to add a line to your .htaccess page that says

 

ErrorDocument 404 /yourpage.php

 

[Edited out the .htaccess stuff because I reread the post and I don't think I was answering what it needed to do.]

Edited by owatagal
Posted

ostrich99, if you can, make it a "subdirectory"... ok let me explain this better: instead of making it work with www.domain.com/subdir make it work with www.domain.com/sub/dir. 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 www.domain.com/subdir would have to catch every link going to your website.

  • 3 weeks later...
Posted

All,

 

Well I got this sorta working using a custom php error page for a 404.

 

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.

 

Really sucks as this script I wrote works really well, and works fine in Firefox, etc.

 

SO, it looks like I have to go the .htaccess route.

 

Anyone have any idea of I'll have similar issues with that method?

 

Ostrich99

Guest Serpentine
Posted

.htaccess will work fine, I use mine for that. IE wont show the other one most likely because the file size it too small.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...