Jump to content

Recommended Posts

I've been using a redirect on my site for years without issue. Someone registers a username with an underscore and now for the username with the underscore doesn't work.

 

Options +FollowSymlinks

Options -Indexes

RewriteEngine on

RewriteRule ^([a-z0-9]+)$ /?L=users.profile&id=$1 [r=301,nc]

 

so if I enter

 

www.mysite.com/username

 

it works with a redirect to users.profile&id=username

 

now the person with an underscore in the username gets a not found error.

 

www.mysite.com/user_name

 

Naturally, the underscore may or may not be there and there could be multiple ones in any position.

 

Does anyone know if this can be fixed?

 

 

Link to comment
https://forums.phpfreaks.com/topic/149457-solved-underscore-messes-up-redirect/
Share on other sites

RewriteRule ^([a-z0-9]+)$ /?L=users.profile&id=$1 [r=301,nc]

 

Change to:

 

RewriteRule ^([a-z0-9_]+)$ /?L=users.profile&id=$1 [r=301,nc]

 

 

Your pattern says 1 a string starting with and ending with 1 or more letters or numbers.  Why would it work with an underscore?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.