Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
Php 永久链接设置错误?_Php_.htaccess_Permalinks - Fatal编程技术网

Php 永久链接设置错误?

Php 永久链接设置错误?,php,.htaccess,permalinks,Php,.htaccess,Permalinks,目前我正在向我的网站添加永久链接。我首先使用.htaccess文件检查URL,该文件使用以下代码: Options +FollowSymLinks RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([\w.'@\\\/-]+)$ profile.php?user=$1 [NC,L] <Files .htaccess> order

目前我正在向我的网站添加永久链接。我首先使用.htaccess文件检查URL,该文件使用以下代码:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w.'@\\\/-]+)$ profile.php?user=$1 [NC,L]

<Files .htaccess>
order allow,deny
deny from all
</Files>
Options+FollowSymLinks
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^([\w.@\\/-]+)$profile.php?用户=$1[NC,L]
命令允许,拒绝
全盘否定

因此,这是用于用户配置文件的永久链接。一个例子是url.com/postin'/profiles/usernamehere。现在,如果usernamehere部分等于数据库中的一个用户名,则会将用户带到该配置文件。如果找到用户名,它会将用户链接到显示信息的profile.php页面,其url为:url.com/postin'/profiles/usernamehere。我想知道的是,这是一个好的方法吗?这似乎很有效,但我觉得我错过了什么或做错了什么。我觉得URL应该是URL.com/postin'/profiles/profile.php?user=usernamehere,但事实并非如此。注意:我确实喜欢现在的方式,但我做错了什么吗?

没有错,这只是一个内部重定向,因此您不会在浏览器的地址栏中看到任何更改(与外部重定向相反,外部重定向会使浏览器对新地址发出第二次请求)。谢谢!:)我只是担心,因为大多数网站完全改变了URL。你知道为什么所有网站都不会只使用内部eDirect吗?外部重定向的好处是什么?如果用户通过不被视为该信息的“主”或“真实”地址(另请参见:规范URL)请求资源,或者出于内部重定向不可行的原因,通常使用外部重定向。如果想要“漂亮的URL”,如
/profile/username
,并将其重写为
somescript.php?parameter=username
,则会使用内部重定向,因为“漂亮的URL”的全部意义在于用户可以看到第一个URL。谢谢!)非常有帮助!:D请将其重新发布为实际帖子,以便我可以对您进行评分,并将其标记为最佳答案!:)