.htaccess with slach isuee

I got this code:

    RewriteEngine On
    RewriteRule   ^!(.+)$  user.php?user=$1 [L]

which works great when typing

    'www.example.com/![username]'

but when i enter

    'www.exaple.com/![username]/'

than my webpage wants to download al data, imagges, css files, javascript from the directory:

    '/![username]/'

how can i ignore the last slach in my htaccess?

+3
source share
2 answers
 RewriteEngine On
 RewriteRule   ^!(.+)[/]?$  user.php?user=$1 [L]

should do it for you. The slash at the end of the URL is optional with [/]?.

EDIT:

, . CSS, JS, .. ; , , URL-, . URL- ( ) URL- :

 RewriteEngine On
 RewriteRule   ^!([^/]*)/$  /!$1 [R=301,L]
 RewriteRule   ^!(.+)$  user.php?user=$1 [L]

... untested.

+2
0

All Articles