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
https://forums.phpfreaks.com/topic/770-mod_aliasmod_rewrite-with-slashes/
Share on other sites

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.