Jump to content

mod_alias/mod_rewrite with slashes


Alcedema

Recommended Posts

Ok, I am one step further with adding trailing slashes when the user misses them out. I have a set of rewrite mod lines which change the incoming address, but they gave a 404 if the user did not add a trailing slash.

 

So I started with redirectmatch lines. These work.

 

This is what I have:

 

 

 

RewriteEngine on

RewriteRule ^([^/]*)/$  /home/nominis/public_html/dev/index.php?id=$1

RewriteRule ^([^/]*)/([^/]*)/$  /home/nominis/public_html/dev/index.php?id=$1&id2=$2

RewriteRule ^([^/]*)/([^/]*)/([^/]*)/$  /home/nominis/public_html/dev/index.php?id=$1&id2=$2&id3=$3

RedirectMatch ^/dev/([^/]*)$ http://www.nominis.net/dev/$1/

RedirectMatch ^/dev/([^/]*)/([^/]*)$ http://www.nominis.net/dev/$1/$2/

RedirectMatch ^/dev/([^/]*)/([^/]*)/([^/]*)$ http://www.nominis.net/dev/$1/$2/$3/

 

Now the redirectmatch works with 2 and 3 variables, but the first line, the one with one variable, doesn\'t work. Always gives \"index.php\" instead of the actual given variable. Also, the redirectmatch line with 2 variables, always puts 2 slashes on the end, instead of one. Is it going through two matches?

 

Anything someone can add?

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.