Reputation: 3002
Do anyone can give some advice on how to do
URL for my php page
I have this URL
website.com/profile.php/8
What I need is this URL
website.com/profile/8
What I do is
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
But it / "Backslash" is reading for another directory, any idea how to fix this ?
Upvotes: 1
Views: 32
Reputation: 784928
You can use these rules:
RewriteEngine On
# Forward /profile/8 to /profile.php/8
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f
RewriteRule ^([\w-]+)/([\w-]+)/?$ $1.php/$2 [L]
# Forward /profile to /profile.php
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
RewriteCond
is to ensure corresponding .php
exists.
Upvotes: 1