How to redirect existing URL rewrites to newer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mfaisalwarraich
    New Member
    • Oct 2007
    • 194

    #1

    How to redirect existing URL rewrites to newer

    Hi everybody,

    I have some rule defined in .htaccess file inside my webroot folder which is working fine. That rule is as follows:

    Code:
     RewriteRule    ^page/([A-Za-z0-9-]+)/?$     index.php?page=$1    [NC,L]    # Process pages
    My current page url according to the above rule can be:
    http://www.mywebsite.c om/page/abc

    and this will be translated to server as:
    http://www.mywebsite.c om?index.php?pa ge=abc

    Now i want to eliminate word page from my existing URL i.e. from http://www.mywebsite.c om/page/abc and want to write it like http://www.mywebsite.c om/abc

    Please tell me how i can do this? or i have to define a separate rule for each n every URL?

    thanx
    regards

    Faisal
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    You would just remove the "page/" from your regular expression. ^([A-Za-z0-9-]+)/?$ would translate all requests like example.com/abc to example.com/index.php?page= abc.

    Comment

    • mfaisalwarraich
      New Member
      • Oct 2007
      • 194

      #3
      i never tested your answer but i found solution to this:

      Code:
      RewriteRule ^([a-zA-Z0-9_-]+)$  index.php?page=$1
      thank you for your reply :).

      Comment

      Working...