Kartik Deshpande Kartik Deshpande - 4 months ago 16
CSS Question

htaccess smart url for listing directories

1> This is the htaccess rule to display a smart URL for the path /uploadr/public folder !!

/uploadr/public folder is the one to list the directories and does not contain any html documents or such

RewriteRule ^Uploadr-Public$ /uploadr/public [L]


However when i access http://localhost/Uploadr-Public in the url the path
mapping works fine but does not display the smart URL (Uploadr-Public)

How can is solve this ?

Heres the screenshot of what it is currently displaying in url!!

enter image description here

2> Also if suppose one wants to access a folder named temp which is in

/var/www/html/uploadr/public/temp


can he specify the path in url as

htttp://localhost/Uploadr-Public/temp


where Uploadr-Public/ is smart URL and temp is a folder inside public

Answer

Issue is that /uploadr/public points to a physical directory and you're not using trailing slash in rewritten path. mod_dir module that runs after mod_rewrite adds a trailing slash in front of directories.

You can use this rule to fix it:

RewriteRule ^Uploadr-Public/(.*)$ /uploadr/public/$1 [L,NC]

Make sure to clear browser cache before testing it.