Reputation: 545
I'm using php for a native project my urls are as follows project.log/share/report1.php
i want to remove .php from urls, if the url entered contained .php remove it, if not act as if it's found
share folder i want to show it as reports too and works vice versa
what i've achieved so far
RewriteEngine on
RewriteRule ^(.+)\.php$ /$1 [R,L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ /$1.php [NC,END]
this successfully remove the .php but i don't know how to add an expression for share folder to replace it's name
Upvotes: 0
Views: 57
Reputation: 785128
You need additional rule to rename share
to reports
:
RewriteEngine on
RewriteRule ^share/(.*?)(\.php)?$ /reports/$1 [R=307,NC,L]
RewriteRule ^(.+)\.php$ /$1 [R=307,NC,L]
RewriteCond %{DOCUMENT_ROOT}/share/$1.php -f
RewriteRule ^reports/(.*)$ share/$1.php [END,NC]
RewriteRule ^reports/(.*)$ share/$1 [END,NC]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [NC,END]
Upvotes: 1