hi friends, am modrewriting my user profile url. Iz nw 'www.mysite.com/username' with that url u can acces user profile direct. But the problem am facing is that if a user UserName Contain '.' eg. 'Www.mysite.com/junkle.junk' it will not open rather its sh0wing me page n0t f0und. Pls hw do i ge rid of it . Tanx
help on modrewrite problem
Collapse
X
-
-
Thiz iz my full .htacess file c0de:
Code:<IfModule mod_rewrite.c> RewriteEngine On Options -Indexes Options +FollowSymlinks RewriteRule ^(.*)\.html$ $1.php [nc] RewriteRule ^([a-zA-Z0-9_-]+)$ userinfo.php?user=$1 [L] RewriteRule ^([a-zA-Z0-9_-]+)/$ userinfo.php?user=$1 [L] RewriteEngine On RewriteCond %{HTTP_HOST} ^[url=http://www.mysite.com]Website Hosting - Mysite.com[/url] RewriteRule (.*) http://mysite.com/$1 [R=301,L] # proc/self/environ? no way! RewriteCond %{QUERY_STRING} proc/self/environ [OR] # Block out any script trying to set a mosConfig value through the URL RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR] # Block out any script trying to base64_encode crap to send via URL RewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR] # Block out any script that includes a <script> tag in URL RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR] # Block out any script trying to set a PHP GLOBALS variable via URL RewriteCond %{QUERY_STRING} GLOBALS(=|[|\%[0-9A-Z]{0,2}) [OR] # Block out any script trying to modify a _REQUEST variable via URL RewriteCond %{QUERY_STRING} _REQUEST(=|[|\%[0-9A-Z]{0,2}) # Send all blocked request to homepage with 403 Forbidden error! RewriteRule ^(.*)$ index.php [F,L] </IfModule>
Last edited by metulj; 26.07.13, 05:23.
Comment
-
Code:RewriteRule ^([a-zA-Z0-9_-\.]+)$ userinfo.php?user=$1 [L] RewriteRule ^([a-zA-Z0-9_-\.]+)/$ userinfo.php?user=$1 [L]
Code:RewriteRule ^([a-zA-Z0-9_\-\.]+)$ userinfo.php?user=$1 [L] RewriteRule ^([a-zA-Z0-9_\-\.]+)/$ userinfo.php?user=$1 [L]
Code:RewriteRule ^([a-zA-Z0-9-.]+)$ userinfo.php?user=$1 [L] RewriteRule ^([a-zA-Z0-9-.]+)/$ userinfo.php?user=$1 [L]
Code:RewriteRule ^([a-zA-Z0-9_.]+)$ userinfo.php?user=$1 [L] RewriteRule ^([a-zA-Z0-9_.]+)/$ userinfo.php?user=$1 [L]
Last edited by Junkle; 06.08.13, 02:30.
Comment
-
if you want any letters or symbols to be matched as a user name use:
PHP Code:RewriteRule ^.*$ userinfo.php?user=$1 [L]
just remember to write rules to make sure folders like /images/ are still accessible and you may want to block users from using your folder names in your script also.
Comment
-
S0mthing else so how do u intend me to apply the code n0W? I tried the fell0wing but was n0t w0rking...Code:RewriteRule^.*$userinfo.php? user=$1[L] RewriteRule ^([a-zA-Z0-9_\-\.\/]+)$ userinfo.php?user=$1 [L] RewriteRule ^([a-zA-Z0-9-\_\.\/]+)/$ userinfo.php?user=$1 [L]
Code:RewriteRule^.*$userinfo.php? user=$1[L] RewriteRule ^([a-zA-Z0-9_-]+)$ userinfo.php?user=$1 [L] RewriteRule ^([a-zA-Z0-9-_]+)/$ userinfo.php?user=$1 [L]
Code:RewriteRule ^([a-zA-Z0-9_\-\.\/]+)$ userinfo.php?user=$1 [L] RewriteRule ^([a-zA-Z0-9-\_\.\/]+)/$ userinfo.php?user=$1 [L]
Comment
-
Try adding a second directory into the rule (this will save you having to rewrite for every file/directory) eg:
yoursite.con/directory/yourName
PHP Code:RewriteRule ^ /directory/.*$ userinfo.php?user=$1[L]
I know its not exactly as you want it but it will save your site from running slow from following to many rules, the only other option is to do a string replacement on the symbol "/" in your php script to replace it with something else to get round the forward slash problem
Comment
-
Originally posted by Junkle View PostCode:RewriteRule ^([a-zA-Z0-9_-\.]+)$ userinfo.php?user=$1 [L] RewriteRule ^([a-zA-Z0-9_-\.]+)/$ userinfo.php?user=$1 [L]
Code:RewriteRule ^([a-zA-Z0-9_\-\.]+)$ userinfo.php?user=$1 [L] RewriteRule ^([a-zA-Z0-9_\-\.]+)/$ userinfo.php?user=$1 [L]
Code:RewriteRule ^([a-zA-Z0-9-.]+)$ userinfo.php?user=$1 [L] RewriteRule ^([a-zA-Z0-9-.]+)/$ userinfo.php?user=$1 [L]
Code:RewriteRule ^([a-zA-Z0-9_.]+)$ userinfo.php?user=$1 [L] RewriteRule ^([a-zA-Z0-9_.]+)/$ userinfo.php?user=$1 [L]
<!DOCTYPE html PUBLIC "-//WAPFORUM.RS
Comment
-
Dude Use this one
Code:RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]*)/$ /user.php?username=$1 [L]
this will first check for if any folder with name exist there / any url exist
e.g.
yoursite.com/contact_us
this is not user so if any directory exist it will give it more priority, else it will proceed to your user page.
Comment
-
Originally posted by funtowap View PostDude Use this one
Code:RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]*)/$ /user.php?username=$1 [L]
this will first check for if any folder with name exist there / any url exist
e.g.
yoursite.com/contact_us
this is not user so if any directory exist it will give it more priority, else it will proceed to your user page.Code:RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]*)$ userinfo.php?user=$1 [L] RewriteRule ^([^/]*)/$ userinfo.php?user=$1 [L]
Comment
-
Originally posted by Junkle View Postthanx man. I used your idea to do s0mething like thisCode:RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]*)$ userinfo.php?user=$1 [L] RewriteRule ^([^/]*)/$ userinfo.php?user=$1 [L]
Comment
Comment