PHP script to automate some uploading and adding

Posted on 2005-05-11
Last Modified: 2008-02-20
I'm looking for a script in php to automate some things i do by hand!

on my server i have a file named .htacces wich is located in:


The file .htacces file contains the following content:
[begin .htaccesfile]
#  mod_rewrite in use

RewriteEngine On

RewriteBase /

#  Rules

RewriteRule ^news(.*) news.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php

RedirectMatch permanent ^/media/lolasian.wmv$

RedirectMatch permanent ^/media/volkswagon.wmv$
[/end .htacces file]

Now i want a php page where i can fill in a NAME ( in a field ) then it should download from the ftp the .htacces file add a new line on the bottom of the .htacces and reupload it.

[line should be added to .htacces]
RedirectMatch permanent ^/media/NAME.wmv$
[/line should be added to .htacces]

Here it should replace NAME with the name i insterted in the field.

Could you guys help me out

thnx in advance
Question by:Mr-sark
    LVL 7

    Accepted Solution

    how are you doing the 'download from the ftp'?

    I suggest that you should use a more general-purpose RedirectMatch file - it doesn't make sense that you have to edit .htaccess every time you want to add a file to your website. And I would use aliasmatch instead, perhaps.For example:

    AliasMatch ^/media/([a-z][a-z0-9]*).(wmv|avi|mpg)$ /home/bogmon05/public_html/videos/$1.$2

    Hope that helps

    LVL 7

    Expert Comment

    so... the above 'aliasmatch' would allow you to use ANY URL like

    and it will retreive the file from your 'videos' directory.

    If redirectmatch is what you want, then use that instead of course. Just change the second part back into a URL instead of a file path.



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    As this topic comes over and over again in different forms, I've finally decided to write a short (yea, right...) article / tutorial about pagination with PHP with MySQL database. There are dozens of these kind of tutorials, I know - I wanted to mak…
    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now