Jump to content

httaccess allowing dots in URL?


Go to solution Solved by Ch0cu3r,

Recommended Posts

 

Yes add \. into the square brackets

RewriteRule ^([-a-zA-Z0-9_\.]+)$ userprofile.php?username=$1

Thanks for the help, but I've tried that before. It just makes the userprofile page go unavaliable.

My userprofile page is custom made by me. What I do is use a $_GET to get the username in the URL. Then put it in a query and see if the username exsists in a seo tabel. If so then allow the profile to be displayed. If not then echo out "Profile unavaliable". So that being said, When I change my Rewrite to the Rewrite you provided, it makes the page go "Profile unavaliable"

You need to make sure that $_GET['username'] contains exactly what you're looking for before you query the database.
echo it out, alert it, whatever you feel like doing.

 

Also, it might not hurt to add the word 'username' or 'user' or the letter u in front of the usernames... for instance

 

RewriteRule ^u/([-a-zA-Z0-9_\.]+)$ userprofile.php?username=$1

 

That should match http://domain.com/u/the.rocker

Edited by Zane
  • Solution

Change your .htaccess rewriteRule to

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ([a-z0-9_\.-]+)/? userprofile.php?username=$1 [L,NC]

Then in userprofile.php add

printf('<pre>%s</pre>', print_r($_GET, true));

To make sure the $_GET['username'] is being set correctly

Edited by Ch0cu3r

Change your .htaccess rewriteRule to

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ([a-z0-9_\.-]+)/? userprofile.php?username=$1 [L,NC]

Then in userprofile.php add

printf('<pre>%s</pre>', print_r($_GET, true));

To make sure the $_GET['username'] is being set correctly

Thanks. That did it. Thank you very much.

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.