如何将 url 更改为子文件夹
How to change the url as Subfolder
我的URL是:http://www.website.com/profile.php?username=xyz
但是我想改成这样:http://www.website.com/xyz
是否可以使用 .htaccess
?
我试过了,但它给了我:
Internal Error.
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ! -f
RewriteCond %{REQUEST_FILENAME} ! -d
RewriteRule (.*) profile.php?username=
试试这个代码:
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.+) profile.php?username= [L,QSA]
!
和 -f
之间不应有 space 或 RewriteCond
中的 -d
。
我的URL是:http://www.website.com/profile.php?username=xyz
但是我想改成这样:http://www.website.com/xyz
是否可以使用 .htaccess
?
我试过了,但它给了我:
Internal Error.
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ! -f
RewriteCond %{REQUEST_FILENAME} ! -d
RewriteRule (.*) profile.php?username=
试试这个代码:
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.+) profile.php?username= [L,QSA]
!
和 -f
之间不应有 space 或 RewriteCond
中的 -d
。