I want to implement a rewrite rule in my .htaccess file to show a specific url as a directory of my server. See the code below I written,RewriteRule ^(.*)/$ ?page=$1 [NC]This will rewrites urls like www.mysite.com/abc/ to www.mysite.com/index.php?page=abc.But if I request www.mysite.com/abc then it is throwing an 404 error.How can I write a rewrite rule which will match www.mysite.com/abc and www.mysite.com/abc/ both?  Edit:My current .htaccess file (After Litso's answer's 3rd revision) is like below:##ErrorDocument 401 /index.php?error=401ErrorDocument 400 /index.php?error=400ErrorDocument 403 /index.php?error=403ErrorDocument 500 /index.php?error=500ErrorDocument 404 /index.php?error=404DirectoryIndex index.htm index.html index.phpRewriteEngine onRewriteBase /Options +FollowSymlinksRewriteRule ^(.+)\.html?$ $1.phpRewriteCond !-dRewriteRule ^(.*)/$ ?page=$1 [NC,L]RewriteCond %{REQUEST_URI} !index.phpRewriteRule ^(.*)$ ?page=$1 [NC,L]##
Rewrite rule to show as directory using .htaccess
htaccess;url rewriting;http code 500
updateRewriteCond !-dRewriteRule ^(.*)/$ ?page=$1 [NC,L]RewriteCond %{REQUEST_URI} !index.phpRewriteRule ^(.*)$ ?page=$1 [NC,L]This first rewrites urls with a slash, but only if it's not an existing directory.If that's not found it rewrites urls without a slash (but only if it's not index.php, so already rewritten urls are ignored).