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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    .htaccess wild cards or keywords

    Hi all,

    Is there a way to make a redirect for a filename with no regard to the directory it's being requested in.

    so for example, i want to make a redirect for "admin.sys" and i want this redirect to happen no matter where the file "admin.sys" is requested. for example /content/articles/gallery/admin.sys and /admin.sys would both result in the same file being called up.

    And if that's possible, how about adding to that, so say i request a file like somerandompage.html followed by "-wildcard" can we then run a php file with a token of the page preceeding the "-wildcard".

    An example of a use would be index.html-test "-test" would be the wildcard and would idealy call a specified php file that would run some sort of test on the index.html file.

    so this would turn the address bar into a command line of sorts for use in a website admin system of sorts.

    Well there you go i have no idea if something like this would be possible with out having all the pages generated by a single php files that would interpret such a request. I would like to use htaccess for this use, as i would not need to have all the overhead of a single managing php file for my whole site.


    Thanks,
    Happy 4th Everyone!!!
    Last edited by Cyote101; 07-02-2011 at 08:44 AM.

  • #2
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    2
    Thanks
    0
    Thanked 1 Time in 1 Post
    For sure there is a way to do it. I am also trying to do it but unfortunately I am having issues as well. I cannot really understand why my script will not work in achieving this. Is there any tip that you can share that will help me resolve this issue? apologize but I cannot share my code for now.
    Last edited by ShaneC; 07-07-2011 at 07:09 PM. Reason: Signature Rule Violation

  • Users who have thanked sixthofjuly for this post:

    Cyote101 (07-15-2011)

  • #3
    New Coder
    Join Date
    Jul 2011
    Posts
    67
    Thanks
    0
    Thanked 13 Times in 13 Posts
    It's just a matter of pattern matching with Regex. An example of sending all requests for admin.sys (regardless of path) to the same location would be something along the lines of...

    Code:
    RewriteRule admin\.sys$ /foobar.php [L]
    In theory the same applies for the tokens, however there is no simple way to max n occurances of something, so you'd have to write n rewrite rules to account for n different amount of flags.

  • Users who have thanked Cags for this post:

    Cyote101 (07-15-2011)

  • #4
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts
    thanks for the info. I can see how it would work for redirecting any page to another page in say another directory.

    perhaps i should explain what i'm trying to accomplish. I have a php script that will allow me to edit any page on my site, while looking at the page in the browser. it's very usefull as all changes are done in realtime and on the actual page, so you can really speed the editing side of things up a lot.

    The only problem with this functionality is, every single request for a page will include these php options, through an include. So for heavy traffic sites, it can add a lot of processing overhead. Especially since these functions are rarely used, only when editing a page.

    So my solution for this is to create another php script that will re assemble any desired page to add the php scripts needed for the editor functionality.

    I could go through an admin panel and then navigate to the desired page and that would work fine, but i want to streamline the whole process by allowing me to add a suffix to any standard url. such as my "admin.sys" and then have htaccess redirect the requested url to a specific php file. which will further process the request in the desired manner.


    The only thing about this issue is that the original requested URL needs to be processed by the final php file redirected to by htaccess.

    So there we go, any ideas.

    Thanks


  •  

    Posting Permissions

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