Rewrite Question

Discussion in 'Install/Configuration' started by [/root.], Apr 4, 2007.

  1. [/root.]

    [/root.] New Member

    Hi. I'm putting next rewrite rule
    This rule works but if i'm entering to the site by http://site.com/ i'm getting http://www.site.com// << two slashes at the end. So i removed the slash in rule
    Now all works fine but is this normal for 301 redirect?

    Next trouble is:
    Rule don't work. I want to have url like http://www.site.com/search can you tell me how can i make it? Many thanks.
  2. mistwang

    mistwang LiteSpeed Staff

    If the rewrite rule is configured at vhost level, the matching URL incudes the leading '/', if the rewrite is configured at context or .htaccess level, the leading '/' is part of the "RewriteBase" which is removed from the matching URL.

    So, you should change your rewrite rule to
    Code:
    RewriteRule ^/search(.*) search.php
    It should match.
    The same for your first rewrite rule.
  3. [/root.]

    [/root.] New Member

    Thanks, now all work.
  4. [/root.]

    [/root.] New Member

    Hi again *_* I got next trouble:
    Under apache url's were: http://www.site.com/category/news
    Now i get 404 not found error.
    Here is the url_rewrite.php code
    I think problem in REQUEST_URI part. What do you think?
  5. mistwang

    mistwang LiteSpeed Staff

    I think 404 error is because LSWS cannot find a proper handler script for this URL.
    I guess file $DOC_ROOT/category/news does not exist on your server, request of http://www.site.com/category/news should be rewritten to a php script. Please show me the rewrite rule, or the URL to the target php script, and where you plan to configure the rewrite rule.

    Remember, rewrite at vhost level is different from rewrite rule at directory or .htaccess level, same is true for Apache, if you move rewrite rules from inside a <directory> directive from httpd.conf to vhost level in LSWS, you need add the rewrite base back to the rewrite rule. Or, define a LSWS context and use the same rewrite rule there.
  6. [/root.]

    [/root.] New Member

    Here is the .httaccess code
    I didn't get the second part of your message. Can you tell me step-by-step instruction how can i fix this problem?
  7. mistwang

    mistwang LiteSpeed Staff

    The .htaccess file does not have any rewrite rule to rewrite '/category/...' to a php script.
    Is this part of vBSEO? should it be handled by "vbseo.php"?
    The last rewrite rule for vBSEO should do it.
    Code:
     RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)$ vbseo.php?vbseourl=$1&%{QUERY_STRING} [L]
    You need to turn on rewrite log under "Rewrite" tab, and check error.log to find out why the rewrite fails.

    We have installation service available to help you sort out any problem quickly during your installation if you need. :)
  8. [/root.]

    [/root.] New Member

    No. I'm using Bitrix (http://www.bitrixsoft.com/)
    URL rewriting going through .php file which i posted above
    Seems that lsws can't recognize this part
  9. mistwang

    mistwang LiteSpeed Staff

    If the 404 error page is generated in PHP, then it might be the problem you mentioned, if the 404 error page is LSWS' default error page, the php script has not been reached at all.

    Turn on debug logging by set "Debug Level" to "HIGH" under "Server"->"log" tab, you should be able to get some clue in the error.log
  10. [/root.]

    [/root.] New Member

    Here we go:
  11. mistwang

    mistwang LiteSpeed Staff

    It is obvious why you get 404
    Code:
    File not found [/srv/www/vhosts/womenscult.com/httpdocs/category/shopping-fashion]
    You need to create a rewrite rule to redirect the request to the php script which supposes to handle all requests to URI "/category/...". That's the suggestion we can give based on the information we got.

    I am surprised that you are still use fastCGI php instead of our LSAPI php.
  12. mistwang

    mistwang LiteSpeed Staff

  13. [/root.]

    [/root.] New Member

    Hm. I need to do this for each category and every article?

    And about LSAPI. I tried to install it but have
  14. mistwang

    mistwang LiteSpeed Staff

    If all categories are handled by one php script, you only need one rewrite rule.

    For the PHP build problem, you may need to do
    Code:
    make clean
    first.

    Again, if you think it is too much for you to handle it, we have one installation service for $149 . :)
  15. [/root.]

    [/root.] New Member

    Can you give me an example?

    For the PHP build problem, you may need to do
    Code:
    make clean
    first.

    Again, if you think it is too much for you to handle it, we have one installation service for $149 . :)[/QUOTE]
    Thanks, i'll try again if it won't install i'll contact with you via support email.
  16. [/root.]

    [/root.] New Member

  17. mistwang

    mistwang LiteSpeed Staff

    The php issue should be fixed first.
    For the rewrite rule try something like
    Code:
    RewriteRule ^/category/   /URL/to/PHP/SCRIPT

Share This Page