Php 按配置文件名称重写url
我的URL重写有问题。我想通过用户名获取url,比如Php 按配置文件名称重写url,php,regex,.htaccess,mod-rewrite,Php,Regex,.htaccess,Mod Rewrite,我的URL重写有问题。我想通过用户名获取url,比如 yourdomain.com/joshua 但厄罗号保持在404 .htaccess ErrorDocument 404 /eror/404.php ErrorDocument 403 /eror/403.php ErrorDocument 500 /eror/403.php RewriteEngine on RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.re
yourdomain.com/joshua
但厄罗号保持在404
.htaccess
ErrorDocument 404 /eror/404.php
ErrorDocument 403 /eror/403.php
ErrorDocument 500 /eror/403.php
RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.recettes.nl/$1 [R,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^about$ about.php
RewriteRule ^recettes$ recettes.php
RewriteRule ^contact$ contact.php
RewriteRule ^([A-Za-z0-9-]+)/?$ profile.php?user=$1 [QSA,L]
RewriteRule ^recept$ recept.php
RewriteRule ^login$ login.php
RewriteRule ^logout$ logout.php
RewriteRule ^register$ register.php
.profile.php
if(!(isset($_GET['user']) && $_GET['user'] == $me['id'] || !isset($_GET['user'])) || isset($me)) {
redirectByPermission('profiles');
}
function notempty($str) {
return ($str != '');
}
if(isset($_GET['user'])) {
$user_sql = $dbh->prepare('SELECT * FROM users WHERE id = :id');
$user_sql->bindParam(':id', trim($_GET['user']), PDO::PARAM_INT);
$user_sql->execute();
$user = $user_sql->fetch();
}else{
$user = $me;
}
谁能帮我一下,告诉我我做错了什么吗?试试这个
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?name=$1 [QSA,L]
希望它能对您有所帮助。您可以通过以下方式完全访问
ErrorDocument 404 /eror/404.php
ErrorDocument 403 /eror/403.php
ErrorDocument 500 /eror/403.php
RewriteEngine on
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
RewriteRule ^(about|recettes|contact|login|logout|register)/?$ $1.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9-]+)/?$ profile.php?user=$1 [QSA,L]
请确保在清除浏览器缓存后对其进行测试。您只需要:
RewriteRule^([A-Za-z0-9-]+)/?$profile.php?user=$1[QSA,L]
@anubhava it-it-give-ERR\u-TOO\u-MANY\u\u重定向eror。此规则甚至不重定向,因此您有一些其他冲突的规则。不在注释中,编辑你的问题并在那里提供你的代码。Oké@anubhava很酷:PThnx,我会试试,我已经重写了引擎等。但是没有-d和-f。我已经更改了它,并为页面提供了thnx:-)但是根据个人资料,我仍然得到了错误的重定向,这是一个测试配置文件否,除非有其他代码或规则,否则此代码不会重定向到/profile
我发现了问题,我有一个脚本阻止了非脱机用户,您需要在查看页面时登录。