0

I would really appreciate some help with a mod_rewrite, I know there is 64K answers on Stack Exchange about this topic and my answer is probably in there somewhere if only I could find the ones to put together to do this

These rules need to be fully and exactly implemented, without the risk of infinite loops, 500 errors or reduced server security.

  1. NO browser redirect - so rewrite, is internal only ... browser bar remains unchanged

  2. file_names.any_extension that do not exist redirect to /error/index.php whether non existent file is in html root or subdirs.

  3. The following should be left untouched and exhibit default behaviour EXAMPLES:

    URL/ 
    

    OR URL/?bla-bla OR URL?bla-bla

    OR URL/an_exist_file.ext

    OR URL/an_exist_file.ext?bla-bla

    OR URL/an_exist_file.ext/?bla-bla

    AND all of above with an additional existing path such as:

    URL/any_path_that_exists/an_exist_file.ext AND with OR without a query string.
    
  4. HOWEVER the following should always rewrite internally to URL/?path_or_string_that_does_not_exist and $_SERVER[["REQUEST_URI"] should contain that non existent path // string; EXAMPLES:

    URL/a_path_that_does_not_exist/
    

    OR URL/a_string_that_is_not_an_existing_path (without trailing slash)

    AND URL/a_path_that_does_not_exist/a_file_name_that_exists_in_html_root.ext is processed from html root and non existent path rewrites to a query string.

I hope that is clear. If anyone can help me with this it would be much appreciated. I have read all apache notes on subject (gave me a headache) and googled, looked up umpteen stack overflow articles, but was unable to come up with something to do all of the above reliably and together. Should be simple but for me it proving difficult.

  • 2
  • Yes another of the many thousands of generic tutorials on the subject and no doubt a few hours of stuffing around I could figure it out,from those tutorials, however that does not address the specific question I asked nor does it help any one else that is a novice and wants to do the same sort of thing - Thankyou for you advice! – user424701 Jul 13 '17 at 3:51
  • ServerFault isn't a place that will do your work for you, especially not the work of reading and understanding a tutorial. In order to get an answer here, you need to at least show some attempts to do the work for yourself first. Then read How do I ask a good question and try to rewrite your question so that it matches the site quidelines. Include the following: What have you tried? What did you expect to happen? What happened instead? What does your config look like? Do you have any log entries from the times it didn't work as expected? – Jenny D Jul 13 '17 at 7:45

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.