簡體   English   中英

GET無法與.htaccess干凈網址一起使用

[英]GET doesn't work with .htaccess clean url

我正在制作一個配置文件系統,並使用localhost/profiles?user=ryr11可以工作,並且我嘗試使用

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

RewriteRule ^profiles/(.+)$ profiles.php?user=$1 [L,QSA]

這樣我就可以使用localhost/profiles/ryr11 ,但是當我這樣做時,我不再收到404錯誤,但是使用$_GET['user']不再有效。

嘗試這個:

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-d 
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^profiles/([a-zA-Z0-9_.-]+)/?$ profiles.php?user=$1 [L,NC,QSA]

保持這樣的規則:

Options  -MultiViews
RewriteEngine On
RewriteBase /

RewriteRule ^profiles/(.+)$ profiles.php?user=$1 [L,QSA,NC]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f [NC]
RewriteRule ^(.+?)/?$ $1.php [NC,L]

您需要再次解碼該網址才能將其刪除。

用這個

$user = $_GET['user'];
$postTitle = str_replace("-", " ", $user);

這應該再次工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM