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 9 of 9
  1. #1
    Senior Coder
    Join Date
    May 2006
    Posts
    1,680
    Thanks
    28
    Thanked 4 Times in 4 Posts

    mod rewrite for xml redirect problem ??

    Hi,

    I have written a simple script to generate my rss file on demand.

    The script is on http://simpg.net/rss_feed.php?rss=$1

    As you can see it take the rss variable to locate page.

    I want to use a url which is related to the page
    so it will be like this:

    http://villarentfethiye.simpg.net/rss-feed-5.xml

    So in my .htaccess file, I have:

    Code:
    # GETTING RSS FILE BY PAGE NUMBER 
    # http://villarentfethiye.simpg.net/rss-feed-5.xml
    
    RewriteCond %{HTTP_HOST} ^(.+).simpg.net$ [NC]
    RewriteCond %{HTTP_HOST} !^www.simpg.net$ [NC]
    RewriteRule ^[\.0-9,:\/-a-z]+rss-feed-([0-9]+)\.xml$ http://simpg.net/rss_feed.php?rss=$1 [NC,QSA,L]
    I also have in the same htaccess file this:

    ( immediately after the above )

    Code:
    # GETTING SUPPORT PAGE BY PAGE NO
    # http://some-name.simpg.net/greatest-gadget/p1.html
    
    RewriteCond %{HTTP_HOST} ^(.+).simpg.net$ [NC]
    RewriteCond %{HTTP_HOST} !^www.simpg.net$ [NC]
    RewriteRule ^[\.0-9,:\/-a-z]+-p([0-9]+)\.html$ http://simpg.net/info.php?p=$1 [NC,QSA,L]
    When I click on my link, my server runs the info.php script
    and not the rss_feed.php script.

    Can antony see what I have 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
    Senior Coder
    Join Date
    May 2006
    Posts
    1,680
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Can anyone help me on this ?

    I think it is a fairly basic Mod Re-write but I am not
    very familiar with this.

    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.

  • #3
    Senior Coder
    Join Date
    May 2006
    Posts
    1,680
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Oh dear ... I don't think anyone visits this sub-forum

    If anyone does see this this and knows what I did wrong.

    Please show me

    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
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,302
    Thanks
    28
    Thanked 276 Times in 270 Posts
    Quote Originally Posted by jeddi View Post
    If anyone does see this this and knows what I did wrong.
    It's pretty evident that code you're not showing is affecting the result. Otherwise, I don't see how you get a redirect from http://villarentfethiye.simpg.net/rss-feed-5.xml to http://simpg.net/info.php?a=villarentfethiye.

    Make sure that the code you think you're running is what is actually uploaded to the server.

    Also make sure that you do not have other .htaccess files affecting the result; more than one such file can be applied at the same time. It may help to replace the L flag with the END flag; I believe that prevents chaining of .htaccess files.
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #5
    Senior Coder
    Join Date
    May 2006
    Posts
    1,680
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Yes - you are correct ...

    Full .htaccess :

    Options +SymLinksifOwnerMatch
    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]
    #
    ######################################################

    # Redirect old file path to new file path
    # Redirect vacationvillasfethiyerental.villarentfethiye.simpg.net http://example.com/newdirectory/newfile.html
    #
    # To block an IP address:
    # RewriteCond %{REMOTE_ADDR} ^(A\.B\.C\.D)$
    # RewriteRule ^/* http://www.domain.com/sorry.html [L]

    # Re-direct for broken images
    # RewriteCond %{REQUEST_FILENAME} !-f
    # RewriteRule ^images/.*\.jpg$ /images/default.jpg [L]

    # GETTING RSS FILE BY PAGE NUMBER
    # http://villarentfethiye.simpg.net/rss_feed-5.xml

    RewriteCond %{HTTP_HOST} ^(.+).simpg.net$ [NC]
    RewriteCond %{HTTP_HOST} !^www.simpg.net$ [NC]
    RewriteRule ^(.*?)rss_feed-([0-9]+)\.xml$ rss_feed.php?rss=$2 [NC,QSA,L]

    # GETTING SUPPORTING PAGES BY PAGE NO
    # http://some-name.mobi6.net/greatest-gadget-p13.html

    RewriteCond %{HTTP_HOST} ^(.+).simpg.net$ [NC]
    RewriteCond %{HTTP_HOST} !^www.simpg.net$ [NC]
    RewriteRule ^(.*?)-p([0-9]+)\.html$ info.php?p=$2 [NC,QSA,L]

    # GETTING MAIN PAGE BY URL NAME
    RewriteCond %{HTTP_HOST} ^(.+).simpg.net$ [NC]
    RewriteCond %{HTTP_HOST} !^www.simpg.net$ [NC]
    RewriteRule ^.*$ http://simpg.net/info.php?a=%1 [NC,QSA,L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ 404.php?url=$1 [L]


    .
    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
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,302
    Thanks
    28
    Thanked 276 Times in 270 Posts
    Quote Originally Posted by jeddi View Post
    RewriteCond %{HTTP_HOST} ^(.+).simpg.net$ [NC]
    RewriteCond %{HTTP_HOST} !^www.simpg.net$ [NC]
    RewriteRule ^(.*?)rss_feed-([0-9]+)\.xml$ rss_feed.php?rss=$2 [NC,QSA,L]
    This rule doesn't match the one you showed earlier. It has an underscore instead of a hyphen after "rss" and therefore will never match http://villarentfethiye.simpg.net/rss-feed-5.xml.

    Quote Originally Posted by jeddi View Post
    RewriteCond %{HTTP_HOST} ^(.+).simpg.net$ [NC]
    RewriteCond %{HTTP_HOST} !^www.simpg.net$ [NC]
    RewriteRule ^.*$ http://simpg.net/info.php?a=%1 [NC,QSA,L]
    Instead, it matches this rule.

    In the case of the URL http://villarentfethiye.simpg.net/rss_feed-5.xml (with an underscore), the first rule (quoted above) will match. However, the URL will be sent to the URL handler, and the .htaccess file will cause the URL to be re-processed and match the second rule. Try using an END flag instead of the L flag as I suggested earlier to prevent this.

    Alternatively, try changing your RewriteCond directives so that they aren't identical between rules or your RewriteRule directives to be more strict in what they match.
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #7
    Senior Coder
    Join Date
    May 2006
    Posts
    1,680
    Thanks
    28
    Thanked 4 Times in 4 Posts
    You are correct ... I did change the hyphen to an underscore

    I have done it in both the url link and the rewrite rule.

    I tried putting END instead of L - but my server gives 500 Server Error
    with that.

    What I don't understand is why does my
    # GETTING SUPPORTING PAGES re-direct work OK
    ... without causing this re-re-direct

    and yet my
    # GETTING RSS FILE BY PAGE re-direct does NOT work.

    both seem to be very similar in rules and conditions.


    This is what I have now :
    # Redirect old file path to new file path
    # Redirect vacationvillasfethiyerental.villarentfethiye.simpg.net http://example.com/newdirectory/newfile.html

    # Re-direct for broken images
    # RewriteCond %{REQUEST_FILENAME} !-f
    # RewriteRule ^images/.*\.jpg$ /images/default.jpg [L]

    # GETTING RSS FILE BY PAGE NUMBER
    # http://villarentfethiye.simpg.net/rss_feed-5.xml

    RewriteCond %{HTTP_HOST} ^(.+).simpg.net$ [NC]
    RewriteCond %{HTTP_HOST} !^www.simpg.net$ [NC]
    RewriteRule ^(.*?)rss_feed-([0-9]+)\.xml$ rss_feed.php?rss=$2 [NC,QSA,L]

    # GETTING SUPPORTING PAGES BY PAGE NO
    # http://some-name.mobi6.net/greatest-gadget-p13.html

    RewriteCond %{HTTP_HOST} ^(.+).simpg.net$ [NC]
    RewriteCond %{HTTP_HOST} !^www.simpg.net$ [NC]
    RewriteRule ^(.*?)-p([0-9]+)\.html$ info.php?p=$2 [NC,QSA,L]

    # GETTING MAIN PAGE BY URL NAME
    RewriteCond %{HTTP_HOST} ^(.+).simpg.net$ [NC]
    RewriteCond %{HTTP_HOST} !^www.simpg.net$ [NC]
    RewriteRule ^.*$ http://simpg.net/info.php?a=%1 [NC,QSA,L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ 404.php?url=$1 [L]
    Any more thoughts on how I can fix this ?

    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.

  • #8
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,302
    Thanks
    28
    Thanked 276 Times in 270 Posts
    Quote Originally Posted by jeddi View Post
    I tried putting END instead of L - but my server gives 500 Server Error
    with that.
    Hmm... Apparently that keyword was added in Apache 2.4. If your host is using an older version of Apache, it won't work. See http://httpd.apache.org/docs/current...tures_2_4.html under mod_rewrite.

    It looks like you're going to have to simply tighten up your rules.

    Quote Originally Posted by jeddi View Post
    What I don't understand is why does my
    # GETTING SUPPORTING PAGES re-direct work OK
    ... without causing this re-re-direct
    Really? I just tested your URL, http://some-name.mobi6.net/greatest-gadget-p13.html, and it doesn't "work OK". Changing the URL to http://some-name.simpg.net/greatest-gadget-p13.html demonstrates that this rule has the same issue as the RSS rule.

    Quote Originally Posted by jeddi View Post
    and yet my
    # GETTING RSS FILE BY PAGE re-direct does NOT work.
    I still think this code is the root of the problem:

    Code:
    RewriteCond %{HTTP_HOST} ^(.+).simpg.net$ [NC]
    RewriteCond %{HTTP_HOST} !^www.simpg.net$ [NC]
    RewriteRule ^.*$ http://simpg.net/info.php?a=%1 [NC,QSA,L]
    Look at:

    Code:
    RewriteCond %{HTTP_HOST} ^(.+).simpg.net$ [NC]
    RewriteCond %{HTTP_HOST} !^www.simpg.net$ [NC]
    RewriteRule ^(.*?)rss_feed-([0-9]+)\.xml$ rss_feed.php?rss=$2 [NC,QSA,L]
    This code takes the URL http://villarentfethiye.simpg.net/rss_feed-5.xml and spits out the URL http://villarentfethiye.simpg.net/rss_feed.php?rss=5. That matches everything in the first code block and redirects to http://simpg.net/info.php?a=villarentfethiye&rss=5.

    One solution would seem to involve redirecting to an absolute URL in the RSS rule. Alternatively, you could tighten up the "MAIN PAGE" rule to exclude processing URLs which contain the term "rss".

    You may also want to tighten up your rewritecond rules. Unescaped periods/full stops indicate "any character".
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #9
    Senior Coder
    Join Date
    May 2006
    Posts
    1,680
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Hmm... Apparently that keyword was added in Apache 2.4. If your host is using an older version of Apache, it won't work. See http://httpd.apache.org/docs/current...tures_2_4.html
    OK - thanks for checking that

    My server uses 2.2.15.

    I will see about getting it upgraded.
    Looks like the best solution.


    .
    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.


  •  

    Posting Permissions

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