Shadow Jolteon Posted June 4, 2012 Share Posted June 4, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/263613-apache-configuration-rewriterule-at-document-root/ Share on other sites More sharing options...
requinix Posted June 4, 2012 Share Posted June 4, 2012 Doesn't work well how? What if you remove the leading slash? Quote Link to comment https://forums.phpfreaks.com/topic/263613-apache-configuration-rewriterule-at-document-root/#findComment-1351033 Share on other sites More sharing options...
Shadow Jolteon Posted June 4, 2012 Author Share Posted June 4, 2012 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. ^^ Quote Link to comment https://forums.phpfreaks.com/topic/263613-apache-configuration-rewriterule-at-document-root/#findComment-1351048 Share on other sites More sharing options...
Shadow Jolteon Posted June 4, 2012 Author Share Posted June 4, 2012 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! ^^ Quote Link to comment https://forums.phpfreaks.com/topic/263613-apache-configuration-rewriterule-at-document-root/#findComment-1351102 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.