Jump to content

Recommended Posts

Hello,

 

On my server, I am trying to make it so that the "name" parameter is passed to a file called "profile.php" using RewriteRule. Unfortunately, my skills with this and regular expressions are greatly lacking. Here is what I presently have:

 

RewriteEngine on
RewriteRule ^/([A-Za-z0-9]+)                     profile.php?name=$1                     [NC]

 

What I am wanting to do is this: If a user visits http://mydomain.com/andrew it would appear to PHP as profile.php?name=andrew, unless a file in the directory has that name. I needed to do this as alphanumeric, with capitol characters allowed, and only six characters, but the above code is all I could scrap together, and it doesn't work well at all.

 

Thank you for reading, and for any help,

Shadow Jolteon

I get the same result removing the slash.

 

The problem here is that it doesn't seem to care whether or not the file fits those rules. If they do, it passes the name parameter to the profile.php file, otherwise it just redirects it to the file without the parameter. What I would prefer it to do would be if it does not fit the rules, to display a file that has that name as it normally would.

 

Thanks for the reply!

 

Ps. Nice kemonomimi avatar. ^^

I finally figured it out!

 

Here's what I did, it doesn't do the six characters or less thing I wanted, but for what I'm using it for it will work for now:

RewriteEngine On
RewriteRule ^(.[A-Za-z0-9]+)$       profile.php?name=$1 [NC]

 

Thank you again for the reply! ^^

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.