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!

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!

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    :)

Archived

This topic is now archived and is closed to further replies.

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