我正在尝试制作它,以便您可以访问此类用户个人资料... site.co.uk/'username'目前我已将我的个人资料页面中的代码更改为这样...... < / p>
<?php
include 'core/init.php';
if (isset($_GET['username']) === true && empty($_GET['username']) === false) {
$username = $_GET['username'];
echo $username;
} else {
header('Location: index.php');
exit();
}
?>
我尝试将以下代码添加到我的.htaccess文件中以使其工作:
//RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !=f
RewriteCond %{REQUEST_FILENAME} !=d
RewriteRule ^(.*)$ /userprofile.php?username=$1
问题是,当我尝试访问我的网站时,它会将我发送到webhost提供程序的错误页面(000webhost.com)。无论我尝试过什么,我都无法让它发挥作用?任何小编辑都会占用整个网站?以下是在您上传网站之前原始.htaccess代码在服务器上已经上传的方式(可以正常使用):
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.htm user_signup.php user_default_page.php index.html index.shtml index.php
</IfModule>
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
</ifmodule>
<IfModule mod_headers.c>
<FilesMatch "\.(css|js|jpg|jpeg|gif|png|bmp)$">
Header set Cache-Control "max-age=604800, private, must-revalidate"
</FilesMatch>
Header set Vary "Accept-Encoding"
</ifmodule>
IndexIgnore *
<FilesMatch .htaccess>
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^thankyou-page=([0-9]*)$
RewriteRule ^(.*)$ affilates_redirect.php [L]
</IfModule>
ErrorDocument 404 /404.php
非常感谢任何帮助或建议!谢谢大师!
答案 0 :(得分:3)
这些不是有效的规则
RewriteCond %{REQUEST_FILENAME} !=f
RewriteCond %{REQUEST_FILENAME} !=d
在这种情况下,f
和d
是标志,应以短划线( - )开头,而不是等号(=)。
尝试将其更改为:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d