Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Senior Coder
    Join Date
    May 2006
    Posts
    1,683
    Thanks
    28
    Thanked 4 Times in 4 Posts

    Problems with my mod rewrite

    Hi,

    I am trying to make my user to redirect when they go to a certain directory.

    Eg when the url is :
    http://simpg.net/info/learnturkish
    or
    http://www.simpg.net/info/learnturkish

    The redirection should go to :
    http://simpg.net/info.php?a=learnturkish

    If have tried the following.
    Code:
    RewriteCond %{HTTP_HOST} simpg.net [NC]
    RewriteCond %{REQUEST_URI} ^/info/ [NC]
    RewriteRule ^(.*)$ http://simpg.net/info.php?a=%1 [NC,QSA,L]
    But it is not working.

    It seems that the "learnturkish" is not getting passed.

    What have I done wrong ?

    Thanks.
    If you want to attract and keep more clients, then offer great customer support.

    Support-Focus.com. automates the process and gives you a trust seal to place on your website.
    I recommend that you at least take the 30 day free trial.

  • #2
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    723
    Thanks
    20
    Thanked 84 Times in 84 Posts
    this is the rule i have:

    Code:
    Options +FollowSymLinks
    RewriteEngine on
    
    RewriteRule index(.*)\.htm$ index.php
    RewriteRule (.*)_Home\.htm$ index.php
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  • #3
    Senior Coder
    Join Date
    May 2006
    Posts
    1,683
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Hi,

    I have tried another 2 options

    but I can not seem to get this working


    I would like :

    1.mbpg.net

    and


    mbpg.net/coupons/1

    to get redirected to :

    http://mbpg.net/coupon.php?a=1

    So I have tried these.

    Code:
    RewriteCond %{HTTP_HOST} ^([^.]+).mbpg.net [NC]
    RewriteCond %{HTTP_HOST} !=www.mbpg.net [NC]
    RewriteRule ^.*$ http://mbpg.net/coupon.php?a=%1 [NC,QSA,L]
    
    RewriteCond %{HTTP_HOST} mbpg.net/coupons/^([^.]+) [NC]
    RewriteRule ^.*$ http://mbpg.net/coupon.php?a=%1 [NC,QSA,L]
    Can anyone help ?

    Thanks.


    .
    If you want to attract and keep more clients, then offer great customer support.

    Support-Focus.com. automates the process and gives you a trust seal to place on your website.
    I recommend that you at least take the 30 day free trial.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Not sure why this is in the PHP section since it has nothing to do with PHP. Moving to apache configurations.

    Can you get any mod_rewrite to work? Use this for your rewrite engine to verify:
    Code:
    RewriteEngine On
    RewriteRule ^/coupons/([^.]+)$ coupon.php?a=$1 [NC,QSA,L]

  • #5
    Senior Coder
    Join Date
    May 2006
    Posts
    1,683
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Hi,

    Thanks for helping out.

    I tried what you suggested.

    Here is my .htaccess file:

    Code:
    Options +FollowSymLinks 
    RewriteEngine On
    
    # BELOW IS STUFF TO BLOCK SPAMMING ATTACKS 
    ######################################################
    # 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 [NC,L]
    #
    ######################################################
    
    RewriteRule ^/coupons/([^.]+)$ coupon.php?a=$1 [NC,QSA,L]
    But when I enter this:
    http://www.mbpg.net/coupons/1

    Not Found

    The requested URL /coupons/1 was not found on this server.
    But when I enter this:
    http://www.mbpg.net/coupon.php?a=1

    I get my test page come up.

    So looks like this redirect isn't working.

    Redirects on other sites on this server are working OK

    There must be something I have done wrong ??



    .
    If you want to attract and keep more clients, then offer great customer support.

    Support-Focus.com. automates the process and gives you a trust seal to place on your website.
    I recommend that you at least take the 30 day free trial.

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    How did I end up with not all chars.
    Try with *only* this: RewriteRule coupons/(.+)$ coupon.php?a=$1 [NC,QSA,L] and the rewrite engine enabling. If that still doesn't work with coupons/x, then you cannot use rewrite.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •