Jump to content
  • Advertisement
Sign in to follow this  
NickGravelyn

[web] Intelligently Redirecting Pages

This topic is 3804 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys. Currently I have a big blog at nick.gravelyn.com/code that I want to move up a directory (so it would be nick.gravelyn.com). Is there anyway to set something up that could simply catch any urls pointed in the nick.gravelyn.com/code folder and simply drop that code part? I'm on a server using PHP so any sort of PHP/HTML solution works great for me.

Share this post


Link to post
Share on other sites
Advertisement
The easiest thing to do is simply to add the alias to your webserver configuration. Alternately, just have a script called "code" and get the PATH_INFO server variable and redirect there.

Share this post


Link to post
Share on other sites
How do I get that script to run for all the directories? So say a user types in "http://nick.gravelyn.com/code/somefile.zip", how do I run that script to change that to "http://nick.gravelyn.com/somefile.zip"? I looked into the alias thing but I don't see an easy way to do this (I'm on GoDaddy in case someone knows how).

Thanks again.

Share this post


Link to post
Share on other sites
I don't think you quite took my meaning. The idea is that http://nick.gravelyn.com/code is a file, not a directory. Specifically, it is a script. Now, if you have a script like, say, http://mysite.com/cgi-bin/test-cgi.pl, and you access the address http://mysite.com/cgi-bin/test-cgi.pl/foo/bar, test-cgi.pl will be found by the server and executed. It will receive "/foo/bar" as a server variable. So in your case, you can use that server variable to find out what page the user was trying to access, and redirect them there.

Share this post


Link to post
Share on other sites
I understand that much, but will it work for files with no extensions? For instance my server is a cheap one so I can only run PHP scripts. And the point of this is so I don't have to go update all the links to my site. So somehow I need it to see that code is a script and execute that, but it seems that it won't execute PHP files without the extension.

Share this post


Link to post
Share on other sites
Quote:
Original post by NickGravelyn
For instance my server is a cheap one so I can only run PHP scripts.

Can you use a .htaccess file to have Apache rewrite the URL?

Share this post


Link to post
Share on other sites
Is there an issue with executing ln -s . code/ in the root directory of your website? This can be done using PHP, for instance.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!