Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • URL rewriting using .htaccess

    • 6
    • 4
    • 1
    • 1
    • 0
    • 0
    • 0
    • 1.22k
    Answer it

    Hi,

    I was trying to rewrite a URL in .htaccess file on particular range of id's from 40 to 900. But it is not working as it is supposed to be.
    Actually I want to redirect page if there is any Id from 40 to 190. But is also redirecting ids like 4, 41,42.........49 and so on.

    I tried the following

    RewriteEngine on 
    RewriteCond %{REQUEST_URI} Dehradun/(.*)/([40-190])
    RewriteRule Dehradun/(.*)/([40-190]) sd/pages/location.php?city=Dehradun&Id=120
    

    but it didn't work at all

    Can you please figure it out how to configure the following program. Thanks for the help.

 1 Answer(s)

  • In URL Rewriting in .htaccess file Regular Expression is required.
    To redirect URL between 40 to 900 :
    Regular Expression will be like : (4[0-9] | [5-9][0-9] | [1-9][0-9][0-9] )
    And URL will be like :

    RewriteRule Dehradun/(.*)/(4[0-9]|[5-9][0-9]|[1-9][0-9][0-9])sd/pages/location.php?city=Dehradun&Id=120

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: