.htaccess - putting redirects in an external/include file

They are making page name changes and setting up redirects on this one site I am managing. I would like to set it up so they can put in their own redirects for Apache as they need but I do not want them getting into the .htaccess file - too risky! Is there away to put all the redirects in a single file that I can let them edit? I thought that the mapping features might work but I don't know enough to do it correctly.

Any help greatly appreciated!

The code below is a sample redirect. Note the escaped character, the solution needs to be able to handle such characters at times.
RewriteRule ^don\'t-be-penny-wise-and-pound-foolish$ http://%{HTTP_HOST}/dont-be-penny-wise-and-pound-foolish [R=301,L,NS]

Open in new window

LVL 1
RegProctorAsked:
Who is Participating?
 
caterham_wwwCommented:
Yes, of course.
RewriteEngine on
RewriteMap lookup txt:/var/www/full/path/map.txt
RewriteCond ${lookup:$1} ^(.+)
RewriteRule ^/(.*) http://%{HTTP_HOST}/%1 [R=301,L,NS]
 
 
You'll need a text file like
 
# lookup substitute
don't-be-penny-wise-and-pound-foolish dont-be-penny-wise-and-pound-foolish
a b
foo bar

Open in new window

0
 
caterham_wwwCommented:
You can't include external files into .htaccess files.

What you could do: Write a script which analyzes an external file and - if the directives are ok for you/passes the check - write a new .htaccess file.
0
 
RegProctorAuthor Commented:
Surely there is a way to use RewriteMap after all it is a Rewrite function. I'm just not familiar enough with Apache Rewrite to figure it out.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
caterham_wwwCommented:
If you have access to the httpd.conf in order to define one, yes
0
 
RegProctorAuthor Commented:
Yes I do.
0
 
RegProctorAuthor Commented:
Can you give me an example on how to make this work with the above redirect.
0
 
RegProctorAuthor Commented:
Works like a charm, thanks!
0
 
RegProctorAuthor Commented:
Great solution.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.