.htaccess - htaccess rewrite rule without slash -


i trying , googling hours , can't find solution problem. want rewrite:

domain.com/profile.php?user=abc > domain.com/abc

i use:

rewriterule ^(.*)/$ /profile.php?user=$1 [l] 

which works slash @ end. if try without slash

rewriterule ^(.*)$ /profile.php?user=$1 [l] 

i internal server error!

complete .htaccess

errordocument 404 /errors/404.php errordocument 500 /errors/500.php rewriteengine on rewritecond %{http_host} ^www\.domain\.com$ [nc] rewritecond %{request_uri} !\.(css|jpg|gif|png|jar|js|html|htm|php)$ rewriterule ^(.*)$ http://domain.com/$1 [l,r=301] rewriterule ^share/([^/]*)/$ /share/share.php?id=$1 [l] rewriterule ^(.*)/$ /profile.php?user=$1 [l] <ifmodule mod_deflate.c> <filesmatch "\.(html|php|txt|xml|js|css|svg)$"> setoutputfilter deflate </filesmatch> </ifmodule> browsermatch ^mozilla/4\.0[678] no-gzip browsermatch \bmsie\s7 !no-gzip !gzip-only-text/html 

someboy have idea im doing wrong?

thanks, kornel

with second try, 500 because create infinite loop:
^(.*)$ match profile.php?user=xxx again , again... not case when try ^(.*)/$ because (no trailing slash) won't match profile.php?user=xxx

instead, can have way

rewriteengine on  rewritecond %{http_host} ^www\.domain\.com$ [nc] rewritecond %{request_uri} !\.(css|jpg|gif|png|jar|js|html|htm|php)$ rewriterule ^(.*)$ http://domain.com/$1 [l,r=301]  rewriterule ^share/([^/]*)/$ /share/share.php?id=$1 [l]  rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^(.*)/?$ /profile.php?user=$1 [l] 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -