简体   繁体   中英

.htaccess redirect and rewrite

I'm trying to redirect my user profiles.

The code does work on all "variables", even on "profiles" that dont exist for example localhost/test/flfladlfadl. The page that appears looks almost the same like the existing "profiles" but lacks functionality. The goal is to redirect non existing profiles to an error site ("flfladlfadl" dont exist in database)

My .htaccess code:

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?pageprofile=$1 

This isn't an htaccess thing, as it's not htaccess which is checking if the item exists in your database.

Let's say you assign the resulting row to $user, you would do something like:

if(!$user)
{
  // do something else, maybe a 404 not found
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM