Jump to content

Regex in htaccess


Daleeburg

Recommended Posts

ok i realize this is not php, but i am using it on a php site and a regex is a regex right?

 

I am looking into creating a file protection the only problem is that i can not get this working again. 

 

the address looks like this

 

www.domain.com/file_man/files/2/items.txt

 

This does not work

 

RewriteEngine On
Options +FollowSymLinks

# Rewrite /file_man/files/xxxx/yyyy.zzz to test.php?file=yyyy&type=zzz&user=xxxx
RewriteRule ^file_man/files/([^/]+)/([^\.]+)\.([^/]+)$ /file_man/test.php?file=$2&type=$3&user=$1 [NC,L]

 

This does work

 

RewriteEngine On
Options +FollowSymLinks

# Rewrite /file_man/files/yyyy.zzz to test.php?file=yyyy&type=zzz&
RewriteRule ^file_man/files/([^\.]+)\.([^/]+)$ /file_man/test.php?file=$1&type=$2 [NC,L]

 

the only difference it he third variable which should be a number, any thoughts?

 

~d

Link to comment
https://forums.phpfreaks.com/topic/70480-regex-in-htaccess/
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.