therocker Posted December 9, 2013 Share Posted December 9, 2013 Hello, is it possible to allow dots inside your .htaccess? So like in the URL it would look something like. http://domain.com/the.rocker instead of http://domain.com/therocker Here is my code. RewriteRule ^([-a-zA-Z0-9_]+)$ userprofile.php?username=$1 Link to comment https://forums.phpfreaks.com/topic/284639-httaccess-allowing-dots-in-url/ Share on other sites More sharing options...
Ch0cu3r Posted December 9, 2013 Share Posted December 9, 2013 Yes add \. into the square brackets RewriteRule ^([-a-zA-Z0-9_\.]+)$ userprofile.php?username=$1 Link to comment https://forums.phpfreaks.com/topic/284639-httaccess-allowing-dots-in-url/#findComment-1461754 Share on other sites More sharing options...
therocker Posted December 9, 2013 Author Share Posted December 9, 2013 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" Link to comment https://forums.phpfreaks.com/topic/284639-httaccess-allowing-dots-in-url/#findComment-1461785 Share on other sites More sharing options...
Zane Posted December 9, 2013 Share Posted December 9, 2013 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 Link to comment https://forums.phpfreaks.com/topic/284639-httaccess-allowing-dots-in-url/#findComment-1461791 Share on other sites More sharing options...
therocker Posted December 9, 2013 Author Share Posted December 9, 2013 Here is what I've got. This is the URL that I'm going to be using. This is my database record. This is my code. And this is the .htaccess I tried to use. Link to comment https://forums.phpfreaks.com/topic/284639-httaccess-allowing-dots-in-url/#findComment-1461799 Share on other sites More sharing options...
Ch0cu3r Posted December 9, 2013 Share Posted December 9, 2013 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 Link to comment https://forums.phpfreaks.com/topic/284639-httaccess-allowing-dots-in-url/#findComment-1461803 Share on other sites More sharing options...
therocker Posted December 9, 2013 Author Share Posted December 9, 2013 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. Link to comment https://forums.phpfreaks.com/topic/284639-httaccess-allowing-dots-in-url/#findComment-1461806 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.