Jump to content

httaccess allowing dots in URL?


therocker

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

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.