Bahad001
Bahad001

Reputation: 55

rewrite rule in htaccess with . (dot)

hi this is my first time in stackoverflow so nice to meet you all :) i have my .htaccess file

RewriteRule ^folder/([^/.]+)(/?)$ page.php?x=$1 [L]
RewriteRule ^folder/([^/.]+)/([^/.]+)(/?)$ page.php?x=$1&y=$2 [L]
RewriteRule ^folder/([^/.]+)/([^/.]+)/([^/.]+)(/?)$ page.php?x=$1&y=$2&z=$3 [L]

it work with

http://localhost/test/folder/hello/001/

and

http://localhost/test/folder/hello/001/1/

but with . (dot) doesn't work

http://localhost/test/folder/hello/001.1/

how can i do it and thinks

Upvotes: 1

Views: 1625

Answers (2)

anubhava
anubhava

Reputation: 785491

Remove dot from your negative character class:

# skip rewriting for valid files/directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^folder/([^/]+)/?$ page.php?x=$1 [L]
RewriteRule ^folder/([^/]+)/([^/]+)/?$ page.php?x=$1&y=$2 [L]
RewriteRule ^folder/([^/]+)/([^/]+)/([^/]+)/?$ page.php?x=$1&y=$2&z=$3 [L]

PS: You need first rule here to skip rewriting for valid files/directories

Upvotes: 3

falinsky
falinsky

Reputation: 7428

RewriteRule ^folder/([^/.]+)(/?)$ page.php?x=$1 [L]
RewriteRule ^folder/([^/.]+)/([^/]+)(/?)$ page.php?x=$1&y=$2 [L]
RewriteRule ^folder/([^/.]+)/([^/.]+)/([^/.]+)(/?)$ page.php?x=$1&y=$2&z=$3 [L]

Upvotes: 0

Related Questions