如何重定向.php?User =和.php/?Party = to / using . htaccess文件



这是我的第一个问题,所以如果我做错了什么请告诉我。
我在一个网站上工作,我有网页的网址:
example.net/profile.php/?user=username
example.net/party.php/?party=partyname
我希望他们是:
example.net/profile/username
example.net/party/partyname
我没有任何经验在htaccess所以我的。htaccess文件是:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

DirectoryIndex main.php index.html index.htm index.php
RewriteEngine On
RewriteRule ^profile/([^/]*)$ /profile.php/?user=$1 [L]
RewriteEngine On
RewriteRule ^party/([^/]*)$ /view.php/?party=$1 [L]

但是它不起作用。如果有一个自动重定向的解决方案,那将是完美的。非常感谢您的宝贵时间!

您可以在apache . haccess中使用以下代码删除.php扩展

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]

最新更新