help on modrewrite problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    help on modrewrite problem

    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

    #2
    Lets see the .htaccess
    Mobile chat, iphone chat, android chat, chat, rooms http://www.aiochat.com

    Comment


      #3
      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


        #4
        This?
        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


          #5
          whats wrong with that...

          Comment


            #6
            I hope nothing... ;) Change those two lines in your htaccess file like i wrote and try.
            <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

            Comment


              #7
              Code:
              RewriteRule ^([a-zA-Z0-9_-\.]+)$
              userinfo.php?user=$1 [L]
              RewriteRule ^([a-zA-Z0-9_-\.]+)/$
               userinfo.php?user=$1 [L]
              i did that but i got an eror..

              Code:
              RewriteRule ^([a-zA-Z0-9_\-\.]+)$ userinfo.php?user=$1 [L]
              RewriteRule ^([a-zA-Z0-9_\-\.]+)/$ userinfo.php?user=$1 [L]
              that 0ne affect all my page saying user n0t found. Even with this bel0w
              Code:
              RewriteRule ^([a-zA-Z0-9-.]+)$
              userinfo.php?user=$1 [L]
              RewriteRule ^([a-zA-Z0-9-.]+)/$
               userinfo.php?user=$1 [L]
              and
              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


                #8
                if you want any letters or symbols to be matched as a user name use:
                PHP Code:
                RewriteRule ^.*$ userinfo.php?user=$[L
                by limiting the match to only: a-z A-Z 0-9 _ \- \. it is not matching against anything with / in the username - or alternatively you can add the forward slash into the matched symbols: a-zA-Z0-9_\-\.\/
                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


                  #9
                  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]
                  and
                  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]
                  and
                  Code:
                  RewriteRule ^([a-zA-Z0-9_\-\.\/]+)$
                  userinfo.php?user=$1 [L]
                  RewriteRule ^([a-zA-Z0-9-\_\.\/]+)/$
                   userinfo.php?user=$1 [L]

                  Comment


                    #10
                    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
                    also make sure you don't add the original 2 rules as they will trash this rule >.<

                    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


                      #11
                      Originally posted by Junkle View Post
                      Code:
                      RewriteRule ^([a-zA-Z0-9_-\.]+)$
                      userinfo.php?user=$1 [L]
                      RewriteRule ^([a-zA-Z0-9_-\.]+)/$
                       userinfo.php?user=$1 [L]
                      i did that but i got an eror..

                      Code:
                      RewriteRule ^([a-zA-Z0-9_\-\.]+)$ userinfo.php?user=$1 [L]
                      RewriteRule ^([a-zA-Z0-9_\-\.]+)/$ userinfo.php?user=$1 [L]
                      that 0ne affect all my page saying user n0t found. Even with this bel0w
                      Code:
                      RewriteRule ^([a-zA-Z0-9-.]+)$
                      userinfo.php?user=$1 [L]
                      RewriteRule ^([a-zA-Z0-9-.]+)/$
                       userinfo.php?user=$1 [L]
                      and
                      Code:
                      RewriteRule ^([a-zA-Z0-9_.]+)$
                      userinfo.php?user=$1 [L]
                      RewriteRule ^([a-zA-Z0-9_.]+)/$
                       userinfo.php?user=$1 [L]
                      Did you change the links in page?
                      <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

                      Comment


                        #12
                        Dude Use this one
                        Code:
                        RewriteEngine On
                        RewriteBase /
                        RewriteCond %{REQUEST_FILENAME} !-f
                        RewriteCond %{REQUEST_FILENAME} !-d
                        RewriteRule ^([^/]*)/$ /user.php?username=$1 [L]
                        Use this code for it in your .htaccess of home directory

                        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


                          #13
                          Originally posted by funtowap View Post
                          Dude Use this one
                          Code:
                          RewriteEngine On
                          RewriteBase /
                          RewriteCond %{REQUEST_FILENAME} !-f
                          RewriteCond %{REQUEST_FILENAME} !-d
                          RewriteRule ^([^/]*)/$ /user.php?username=$1 [L]
                          Use this code for it in your .htaccess of home directory

                          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.
                          thanx man. I used your idea to do s0mething like this
                          Code:
                          RewriteEngine On 
                          RewriteBase /
                          RewriteCond %{REQUEST_FILENAME} !-f
                          RewriteCond %{REQUEST_FILENAME} !-d
                          RewriteRule ^([^/]*)$ userinfo.php?user=$1 [L]
                          RewriteRule ^([^/]*)/$ userinfo.php?user=$1 [L]
                          and its works as i wanted. But its still treating f0lders in my home directory as username whereby telling me, username n0t f0und. But only works for three f0lders and i observed that those three folderz are f0lderz that c0ntain .htaccess file in it. What could be the issue here...

                          Comment


                            #14
                            Originally posted by Junkle View Post
                            thanx man. I used your idea to do s0mething like this
                            Code:
                            RewriteEngine On 
                            RewriteBase /
                            RewriteCond %{REQUEST_FILENAME} !-f
                            RewriteCond %{REQUEST_FILENAME} !-d
                            RewriteRule ^([^/]*)$ userinfo.php?user=$1 [L]
                            RewriteRule ^([^/]*)/$ userinfo.php?user=$1 [L]
                            and its works as i wanted. But its still treating f0lders in my home directory as username whereby telling me, username n0t f0und. But only works for three f0lders and i observed that those three folderz are f0lderz that c0ntain .htaccess file in it. What could be the issue here...
                            Sorry? i didnt get your problem this time :D

                            Comment

                            Working...
                            X