Redirecting URL by Apache


Create a .htaccess file in the directory where you want to perform the task. These settings will be applicable to sub-directories also 😉

in the .htaccess file, type the following:
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]+)/([^/]+)/([0-9]+)\.html$ /index.php?maindirectory=$1&subdirectory=$2&articleID=$3

The first set of parentheses will equal your first variable “$1”, the second set of parentheses will equal your second variable “$2”, etc.

The following example will not actually work because of the regular expressions however I’m putting it in here for example:

(.*)/(.*)/(.*) = $1/$2/$3

Side-Note: the reason the above example would fail with the regular expression is that the first (.*) will grab everything including the “/”. That is why I used ([^/]+) in the real example, it says grab everything but “/”.

Source

 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s