Jump to content

URL Redirection based upon Directory Arguments


Mal1t1a

Recommended Posts

Hi,

 

I was wonder if it is possibles, to re-direct someone to a page based upon the Directory Arguments. Here is my Example:

User visits the website MyExample.Com/post/11

The Directory /post/ does exist, however, the directory /11 does not. I want them to be redirected to a webpage with the arguments "11". Is this possible with PHP? If so, please let me know how. Thanks!

Link to comment
Share on other sites

Okay, after reading most of the Page, I have stumbled upon "Trailing Slash Problem". This seems to be it, however I can not manipulate it to work the way I want.

 

The exact thing I'm trying to do is this: "User goes to MyExample.com/2487" "User is re-directed to Post.php?id=2487" The ID based upon the argument specified after the "/". If you could be so kind as to help me with this. Thanks alot!

Link to comment
Share on other sites

This seems to do exactly what I wanted:

Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+) Post.php?id=$1

 

I found this in a few threads down. Thanks for the help anyways guys    :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.