Htaccess ReWrite mod error

Can anybody help me find out solution?
While using this rewrite rule
RewriteRule ^([a-zA-Z0-9_\s]+)/([a-zA-Z0-9_\s]+)/([a-zA-Z0-9._,()&/\s]+)$ loader.php?option=$1&page=$2&storeid=$3 [L]
i got error in server like
RewriteRule: cannot compile regular expression '^([a-zA-Z0-9_\\s]+)/([a-zA-Z0-9_\\s]+)/([a-zA-Z0-9_,()&'/-\\s]+)$'

Comments

  • edited 7:03AM
    There is error on sub folder opening indicating that there is no such folder
  • edited 7:03AM
    hmmm
    ([a-zA-Z0-9._,()&/\s]+) anyproblem on this part? i thought / is special character and need to escaped with '\/'??
  • edited 7:03AM
    will you please write the code so that it will be test.
  • edited 7:03AM
    It does not work after change...
  • edited 7:03AM
    storeid will always be number? or is alphanum?
  • edited 7:03AM
    number
  • edited 7:03AM
    i believe page is also number, maybe can try

    ^([a-zA-Z0-9_\s]+)/([0-9]+)/([0-9]+)$ loader.php?option=$1&page=$2&storeid=$3 [L]
  • edited 7:03AM
    i have tried this one but this will not shown my gallery picture in localhost, i have http://localhost/ft/photogallery/galleryimage/galleryid-71/galcategoryid-12 after this no images display, It will stand in the same page
  • edited 7:03AM
    i think this special character will pass the string to website
  • edited 7:03AM
    hi, if you are using fuel cms, i would suggest you to use route.php under config folder to do the job.

    which means for example if you have a gallery.php in /controller folder and there is a loader function such as public function loader($option,$page,$store)

    you can set the routing in route.php as

    $route['([a-z]+)/([a-z]+)\-(:num)/([a-z]+)\-(:num)']="gallery/loader/$1/$3/$5";
  • edited 7:03AM
    there is error in the - string of the RewriteRule ^([a-zA-Z0-9_\s]+)/([a-zA-Z0-9_\s]+)/([a-zA-Z0-9_,()&'/-\s]+)$ loader.php?option=$1&page=$2&storeid=$3 [L] in all there lines. Is there any other sting instead of -.
  • edited September 2014
    i will try to help, but need more info on this question

    1. you are using fuel cms??
    2. you want to redirect http://localhost/ft/photogallery/galleryimage/galleryid-71/galcategoryid-12 to loader.php?option=galleryimage&page=71&storeid=12??
    3. where you put your loader.php??
  • edited 7:03AM
    1. I am not using fuel cms. I am using smarty template.
    2.
    a). http://localhost/furniture_n/photogallery
    b).photogallery_office furniture: http://localhost/furniture_n/photogallery/type-picture/galcategoryid-12
    c) photogallery_office furniture-executive chair: http://localhost/furniture_n/photogallery/galleryimage/galleryid-71/galcategoryid-12
    d) photogallery_office furniture-executive chair-chair model:http://localhost/furniture_n/images/galleryimage/20131206075747.jpg
    3. loader file is in root directoy
  • edited September 2014
    If loader.php is under furniture_n directory

    you can put the .htaccess like below to redirect a),b),c) above to loader.php by


    Options +FollowSymLinks


    RewriteEngine On
    RewriteBase /furniture_n/


    Order Deny,Allow
    Deny From All


    # Allow option a through
    RewriteRule ^photogallery/?$ loader.php [L,NC]
    # Allow option b through
    RewriteRule ^photogallery/([a-zA-Z0-9]+)\-([a-zA-Z0-9]+)/([a-zA-Z0-9]+)\-([0-9]+)/?$ loader.php?option=$2&storeid=$4 [L,QSA,NC]
    # Allow option c through
    RewriteRule ^photogallery/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)\-([0-9]+)/([a-zA-Z0-9]+)\-([0-9]+)/?$ loader.php?option=$1&page=$3&storeid=$5 [L,QSA,NC]


    Options -Indexes



    on loader.php try

    print_r($_GET);exit;
  • edited 7:03AM
    After placing your code:
    # Allow option a through
    RewriteRule ^photogallery/?$ loader.php [L,NC]
    # Allow option b through
    RewriteRule ^photogallery/([a-zA-Z0-9]+)\-([a-zA-Z0-9]+)/([a-zA-Z0-9]+)\-([0-9]+)/?$ loader.php?option=$2&storeid=$4 [L,QSA,NC]
    # Allow option c through
    RewriteRule ^photogallery/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)\-([0-9]+)/([a-zA-Z0-9]+)\-([0-9]+)/?$ loader.php?option=$1&page=$3&storeid=$5 [L,QSA,NC]

    The error message are:

    Warning: dir(modules/picture): failed to open dir: No such file or directory in /home/wwwmakal/public_html/furni/modules/kernel/class.Kernel.php on line 58

    Fatal error: Call to a member function read() on a non-object in /home/wwwmakal/public_html/furni/modules/kernel/class.Kernel.php on line 59
  • edited 7:03AM
    and the class.Kernel.php codes are:
    line 58 $dir = dir("modules/".$dir_path);
    line 59 while ( false !== ( $entry = $dir->read() ) )
  • edited 7:03AM
    no sure which script you are using, so i am hard to guess the architecture of the whole system. the .htaccess rules above only route to loader.php with $_GET parameters ( as you requested in first post). In loader.php, you will then need to get these parameters and set the $dir_path you want to fetch the images if loader.php includes class.Kernel.php and call any function in it.


    anyway,

    http://localhost/furniture_n/photogallery/type-picture/galcategoryid-12 by using the above .htaccess will pass "picture" to the loader.php , so please check under modules folder if there is a "picture" folder or rather "type-picture" folder. If there is a "type-picture" folder, use

    # Allow option b through
    RewriteRule ^photogallery/([a-zA-Z0-9\-]+)/([a-zA-Z0-9]+)\-([0-9]+)/?$ loader.php?option=$1&page=$3 [L,QSA,NC]

    instead
  • edited 7:03AM
    I ploaded as per your suggetions but still problem. if you want i can send my files
  • edited 7:03AM
    ploaded=uploaded
  • edited 7:03AM
    for options here

    a). http://localhost/furniture_n/photogallery
    b).photogallery_office furniture: http://localhost/furniture_n/photogallery/type-picture/galcategoryid-12
    c) photogallery_office furniture-executive chair: http://localhost/furniture_n/photogallery/galleryimage/galleryid-71/galcategoryid-12
    d) photogallery_office furniture-executive chair-chair model:http://localhost/furniture_n/images/galleryimage/20131206075747.jpg


    currently only option b fail? the rest working?
  • edited 7:03AM
    ok
  • edited 7:03AM
    ok, u can upload to an online drive then share me the link through pm http://forum.getfuelcms.com/messages/add/onegun
  • edited 7:03AM
    Hi,

    i take a look of the script. The flow of the script follows by

    1. reach loader.php
    2. loader.php then load a group of script
    3. loader.php first check url for option parameter if there is then redirect to "option" folders under /modules. If options no specificied redirect to /modules/home
    So rewrite rule

    RewriteRule ^$ loader.php?option=home&page=view [L]
    RewriteRule ^([a-zA-Z0-9_]+)/?$ loader.php?option=$1&page=view [L,QSA]

    4. loader.php second check url for sub parameter if there is then redirect to folders under /modules/{option}/{sub} folder ( this isn't necessary, as i checked the folders under your modules folder, there arent any sub folder.

    so you can ignore this, there isnt any need for rewrite rule for this one

    5. loader.php third check url for page parameter, then redirect to /modules/{option}/{page}.php

    so use

    RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/?$ loader.php?option=$1&page=$2 [L,QSA]

    6. loader.php fourth check url for storeid parameter, the storeid requrested by this system is complex by requesting the format of "galleryid-71/galcategoryid-12/pg-3/type-video", you can observe the pattern here

    in function show() in /modules/photogallery/view.php

    $correctid = getid($_GET['storeid']);
    $galcategorytype = $correctid['type'];
    $this->galcategoryid = $correctid['galcategoryid'];
    if($this->galcategoryid)
    {
    $galcatdetail = $this->getgalCategoryDetail();
    }
    $this->pg = $correctid['pg'];


    in function getid() in global_functions.php

    function getid($storeid)
    {
    //here $storeid is the getid from the url
    $exp=explode('/',$storeid);
    foreach($exp as $key=>$val)
    {
    $tempid=explode('-',$val);
    $correctid[$tempid[0]]=$tempid[1] ;
    }
    return $correctid;

    }

    so

    RewriteRule ^([a-zA-Z0-9_\s]+)/([a-zA-Z0-9_]+)/([a-zA-Z0-9_\/\-&]+)$ loader.php?option=$1&page=$2&storeid=$3 [L,QSA]

    solved the part.

    if you see a lot of missing parameters error, basically because you did not provide parameters values in the url, i would suggest you use isset($_GET['pg']) something like this to handle the issue, and is good for you to define a default value for it.

    complete .htaccess

    Options -Indexes

    RewriteBase /ft/
    RewriteEngine on

    RewriteRule ^$ loader.php?option=home [L]


    RewriteRule ^([a-zA-Z0-9_]+)/?$ loader.php?option=$1&page=view [L,QSA]

    RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/?$ loader.php?option=$1&page=$2 [L,QSA]

    RewriteRule ^([a-zA-Z0-9_\s]+)/([a-zA-Z0-9_]+)/([a-zA-Z0-9_\/\-&]+)$ loader.php?option=$1&page=$2&storeid=$3 [L,QSA]
  • edited 7:03AM
    Still problem:
    Not Found

    The requested URL /furni/photogallery/type-picture/galcategoryid-12 was not found on this server.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
  • edited September 2014
    that is because page parameter is missing from your url as i have explained earlier in my posts. There are two ways for you to solve the problem

    one is to change the url from /furni/photogallery/type-picture/galcategoryid-12 to /furni/photogallery/view/type-picture/galcategoryid-12

    second is to add in this rule RewriteRule ^([a-zA-Z0-9_\s]+)/([a-zA-Z0-9_\/\-&]+)$ loader.php?option=$1&page=view&storeid=$2 [L,QSA]

    in every case you need to try to include a page parameter for your scripts.
  • edited 7:03AM
    will you please advice me for parameters values in the url
  • edited 7:03AM
    I have explained in my september 5 post, please read and digest, thanks
Sign In or Register to comment.