从profile.php更改url?user=myUsername配置文件/myUsername与.htaccess



我正在使用xample在我的电脑上托管我的网页,我想从更改此url

http://localhost/loginsystem/profile.php?user=myUsername

http://localhost/loginsystem/profile/myUsername 

我尝试了以下操作,但没有成功,作为回报,服务器错误为500。

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule ^/profile/([a-zA-Z0-9]+) /profile.php?user=$1 [NC, L]

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule ^/profile/(.*)?$ /profile.php?user=$1 [NC, L]

任何帮助都将是伟大的,仍然是全新的。提前感谢!

这应该可以完成

RewriteRule ^profile/([^/]+)/?$ profile.php?user=$1 [L]

还要确保.htaccess文件位于loginsystem文件夹中。否则你将需要把这个放在你的重写规则

RewriteRule ^loginsystem/profile/([^/]+)/?$ profile.php?user=$1 [L]

将.htaccess代码替换为:

Options +FollowSymLinks
# Turn mod_rewrite on
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^profile/([a-zA-Z0-9]+)/$ profile.php?user=$1 [L]

现在您可以通过get请求获得用户查询。

最新更新