1
我的文件夹中的.htaccess的样子:.htaccess在文件夹中,非www到www。与其他重写规则问题
RewriteEngine On
RewriteBase /profile/
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?username=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?username=$1
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/profile/$1 [R=301,L]
基本上,如果你去www.mySite.com/profile/Username,我的index.php文件采用“用户名”为$ _GET变量,URL看起来干净(www.mySite.com/profile/Username)
但是如果你去mySite.com/profile/username(省略了www),该网址会像http://www.mySite.com/profile/index.php?username=username
我该如何做到这一点,只有添加www而不会搞乱URL?
感谢