'Issue on Using Rewrite Rule From A Folder to A PHP File with Same Name
Having a root directly like below, as you can see I have a Folder and File with same named of shop can you please let me know how to write a RewriteRule in .htaccess to redirect any request like
http://clients/shop/orhttp://clients/shop
to
http://clients/shop.php
I already tried this
RewriteRule ^shop/(.+) shop.php [L,R]
but this is adding wrong address of http://clients/B:/WAMP/www/Clients/shop to the URL
====================
Update
====================
Okay I find this solution which is somehow working
DirectorySlash Off
RewriteEngine on
RewriteCond %{THE_REQUEST} \s/+shop [NC]
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*) /$1.php [R=302,L]
This is however, fine only when the request is like http://clients/shop and it is showing the directory page when the request is like http://clients/shop/
Solution 1:[1]
This should get your job done
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ /shop [NC]
RewriteRule ^shop - [R=404,L]
RewriteRule ^shop/(.*)$ shop.php [L,NC]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

