1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Annoying .htaccess RewriteRule issue

Discussion in 'Web Design' started by jimbobo2779, Feb 23, 2016.

  1. jimbobo2779

    jimbobo2779 Jr. VIP Jr. VIP

    Joined:
    Sep 17, 2008
    Messages:
    3,733
    Likes Received:
    2,659
    Occupation:
    Software Engineer
    Location:
    UK
    Home Page:
    Hey guys I have been having this annoying problem today and despite years of handling redirects I am just having a complete blank with this one.

    I am wanting to do a redirect so that the page below:
    http://domain.com/?someText
    to
    http://domain.com/someText

    and also need it to act as below
    http://domain.com/someText?someMoreText
    to
    http://domain.com/domeTextsomeMoreText

    Essentially pulling out the ? character wherever it appears in the url.

    I have tried the rule below and many many variations of it but I am just being a big idiot about this.
    RewriteRule ^\?(.*)$ $1 [NC,L] #this is for the first variation
    RewriteRule ^\(.*)?(.*)$ $1 [NC,L] # for the second variation

    Any advice on how this may be achieved would be very appreciated.

    Thanks guys.
     
    Last edited: Feb 23, 2016
  2. moon world

    moon world BANNED BANNED

    Joined:
    Nov 7, 2013
    Messages:
    909
    Likes Received:
    156
    Gender:
    Male
    which hosting you use?
     
  3. jimbobo2779

    jimbobo2779 Jr. VIP Jr. VIP

    Joined:
    Sep 17, 2008
    Messages:
    3,733
    Likes Received:
    2,659
    Occupation:
    Software Engineer
    Location:
    UK
    Home Page:
    I have tried on a plesk VPS with mod rewrite enabled as well as my local test server. I don't think it is a problem with the setup on the server so much as it is a problem with the .htaccess code.

    All my other redirects on other domains on the same servers are working fine.

    Thanks for reply, do you have much experience with .htaccess?
     
  4. Asif WILSON Khan

    Asif WILSON Khan Executive VIP Jr. VIP

    Joined:
    Nov 10, 2012
    Messages:
    12,166
    Likes Received:
    33,744
    Gender:
    Male
    Occupation:
    Fun Lovin' Criminal
    Location:
    London
    Home Page: