Problem: Problem when using rewrite rules to redirect a folder to a PHP file with the same name
P粉787820396
P粉787820396 2024-04-04 12:33:52
0
1
536

Directly have the root directory as shown below, as you can see I have a folder and file with the same name as store , you Can you please let me know how to write RewriteRule in .htaccess to redirect any request like

http://clients/shop/ or http://clients/shop

to

http://clients/shop.php

I already tried it

RewriteRule ^shop/(.+) shop.php [L,R]

But this adds the wrong address to the URL

======================

renew

====================

Okay, I found this solution works to some extent

DirectorySlash Off 
RewriteEngine on 
RewriteCond %{THE_REQUEST} \s/+shop [NC]

RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)  /.php [R=302,L]

But, it only works when the request is like http://clients/shop, and it shows the directory page when the request is like http://clients/shop/

P粉787820396
P粉787820396

reply all(1)
P粉129275658

This should do the job for you

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ /shop [NC]
RewriteRule ^shop - [R=404,L]

RewriteRule ^shop/(.*)$ shop.php [L,NC]
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template