.htaccess文件:重定向localhost/ sitellogin /profile/name到localhost


.htaccess file: redirect localhost/sitelogin/profile/name to localhost/sitelogin/profile.php?username=name

我用html和php编写了很多网站。我做了一个用户配置文件系统,但我真的不明白我需要把我的。htaccess文件重定向"localhost/sitellogin/profile/name"到"localhost/sitellogin/profile.php?"username=name"并保留css信息。profile.php包含require '/includes/overall/oheader.php';, include 'includes/head.php';包含<link rel="stylesheet" href="css/screen.css">

我希望能得到直接的帮助,或者一个新手友好的资源,我可以看看有用的信息。

将此代码放入您的DOCUMENT_ROOT/sitelogin/.htaccess文件:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /sitelogin/
RewriteRule ^profile/([^./]+)/?$ profile.php?username=$1 [L,QSA,NC]

对于css/js路径修复,在你的页面的HTML <head>部分使用这个:

<base href="/" />