Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
URL重写访问我的网站_Url_Rewrite - Fatal编程技术网

URL重写访问我的网站

URL重写访问我的网站,url,rewrite,Url,Rewrite,我希望能够在我的网站上访问此URL: www.mysite.com/author/username 通过这个 www.mysite.com/username 请考虑人们可以使用两个URL访问,并且“用户名”总是根据用户而改变。 最好的方法是什么?htaccess重写 谢谢你的时间 如果您的用户创建的名称与现有或未来路径重叠的路径相匹配,则可能会很混乱,并将您限制在其中 RewriteCond %{REQUEST_URI} ^/[a-z]+$ #1 RewriteCond %{REQUEST

我希望能够在我的网站上访问此URL:

www.mysite.com/author/username

通过这个

www.mysite.com/username

请考虑人们可以使用两个URL访问,并且“用户名”总是根据用户而改变。

最好的方法是什么?htaccess重写


谢谢你的时间

如果您的用户创建的名称与现有或未来路径重叠的路径相匹配,则可能会很混乱,并将您限制在其中

RewriteCond %{REQUEST_URI} ^/[a-z]+$    #1
RewriteCond %{REQUEST_FILENAME} !-f     #2
RewriteRule ^/([a-z]+)$ /author/$1 [P]  #3
  • 尽量将其限制为您的用户名模式
  • 仅当路径不存在时才重写
  • URL的/author/username版本的代理

  • 好的,我试试看!谢谢你,阿米尔!