PHP/apacheniceurl
我正在尝试为网站创建漂亮的URL 我有以下文件结构:PHP/apacheniceurl,php,apache,.htaccess,Php,Apache,.htaccess,我正在尝试为网站创建漂亮的URL 我有以下文件结构: public: user: user.php index.php 我想这样做,以便有人可以输入url: http://www.example.com/user/{user name here} 请求将发送至: user.php?name={user name here} 但我不想让他们看到文件 我想我可能不得不用.htacces来做这件事,但我不知道怎么做 如果我的问题布局不是很好,我很抱歉。将此规则放置在/user/.
public:
user:
user.php
index.php
我想这样做,以便有人可以输入url:
http://www.example.com/user/{user name here}
请求将发送至:
user.php?name={user name here}
但我不想让他们看到文件
我想我可能不得不用.htacces来做这件事,但我不知道怎么做
如果我的问题布局不是很好,我很抱歉。将此规则放置在
/user/.htaccess
中:
Options -MultiViews
RewriteEngine On
RewriteBase /user/
RewriteCond %{THE_REQUEST} /user\.php\?name=([^\s&]+) [NC]
RewriteRule ^ %1? [R=302,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ user.php?name=$1 [L,QSA]
看,这工作做得很好!谢谢:)如果允许的话,我会接受的