Results 1 to 6 of 6

Thread: htaccess (is this possible)

  1. #1
    Join Date
    Nov 2009
    Posts
    107
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Default htaccess (is this possible)

    I know its possible to use htaccess for a 301 redirect such as
    Code:
    /olddirectory/oldfile.html http://yoursite.com/newdirectory/newfile.html
    Is it possible to redirect say when a call such as
    Code:
    action
    or
    Code:
    href
    ie
    Code:
    form action="myfile.php" to form action="myfile2.php"
    Is there perhaps a better way to do this? Any help or advice would be appreciated.

    Thanks

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    The fact that a request was triggered by an "action" or "href" attribute is not available to the server.
    However, you can have a rewrite rule for such a page, just like any other:
    Code:
    RewriteEngine On
    RewriteRule myfile.php myfile2.php

  3. #3
    Join Date
    Jan 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    May i ask why you are interested in doing this? Since there may be a better way for you to solve this problem.

  4. #4
    Join Date
    Nov 2009
    Posts
    107
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Default

    I have some work to do on a .html site. The Search Bar is coded into every page. If I change the action I dont want to recode every page to reflect these changes.

  5. #5
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    traq's htaccess rewrite is the one that I'd go with in this case then.

    As this is to fix your search form action, can you not edit the form action php page? That would be the obvious solution to this specific problem...
    Last edited by Beverleyh; 01-08-2013 at 10:40 PM.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  6. #6
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by itivae View Post
    I have some work to do on a .html site. The Search Bar is coded into every page. If I change the action I dont want to recode every page to reflect these changes.
    Actually (while the rewrite I suggested will work just fine), I'd say editing the HTML is the preferable choice (unless it's a temporary change). The redirect will incur overhead (which may not be noticable, but whatever). Additionally, your code would be much more understandable. Just search+replace every instance of action="myfile.php" with action="myfile2.php".

    While you're at it, if you're using PHP anyway, you might want to remove the search bar HTML entirely and place it in a separate file (which you can then include on each page) - it would make changes like these much simpler in the future.

Similar Threads

  1. HTACCESS Help
    By Adnan959 in forum Looking for such a script or service
    Replies: 0
    Last Post: 12-13-2010, 07:59 PM
  2. i need a little help with .htaccess
    By maslove23 in forum PHP
    Replies: 5
    Last Post: 09-23-2008, 12:26 AM
  3. .htaccess
    By Dal in forum Other
    Replies: 3
    Last Post: 09-02-2008, 02:29 PM
  4. .htaccess help
    By davidjmorin in forum Other
    Replies: 1
    Last Post: 02-03-2008, 07:41 PM
  5. .htaccess
    By pcbrainbuster in forum Other
    Replies: 43
    Last Post: 03-12-2007, 10:48 PM

Bookmarks

Posting Permissions

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