mod_rewrite RewriteMap - possible to 404?


 
Thread Tools Search this Thread
Top Forums Web Development mod_rewrite RewriteMap - possible to 404?
# 1  
Old 04-16-2009
mod_rewrite RewriteMap - possible to 404?

In my strenuous efforts to get SEO-friendly urls, I'm using a rewrite map in my apache setup:

Code:
RewriteEngine on
RewriteOptions MaxRedirects=5

RewriteMap seo prg:/Applications/MAMP/htdocs/map.php

#map requests for the original file to the new SEO friendly urls
RewriteCond %{REQUEST_FILENAME} ^/education/db/ug/ug
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -f
RewriteCond %{QUERY_STRING} ^(.+)$
RewriteRule ^/education/db/ug/(ug.*)$ ${seo:$1?%1}? [L,R=301]

My rewrite map is a PHP script which checks my database for an id value supplied in the query string and if anything is found, it returns an SEO-friendly text string which i inject into the URL in order to turn a url like this:
Code:
http://mydomain.com/r.php?id=1234

into one like this:
Code:
http://mydomain.com/amazing-and-useful-url/1234

I'm wondering a few things:
1) If an id is not found in my database, can I send a 404 signal from my map program? If so, how?
2) What's the story with RewriteLock. The documentation is rather tightlipped about the need for it. Am I to understand that if I use a PHP script (or any other program) as a rewrite map that I need a RewriteLock file? What are the required permissions on this file? Can I assume that apache needs to read/write it and will maintain anything it might contain?
3) I'm getting quite concerned about a lengthy list of RewriteCond and RewriteRule items in this particular apache conf file. Is there any way to have apache skip the remainder of rules in this conf file if one fails?
4) is PHP a poor choice for this application? If my map daemon crashes, won't part of my site will go dark?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Web Development

Mod_rewrite to handle paths ?

I hope someone can help. I somewhat know what a mod_rewrite does which is URL rewiring. What I don't know is how to make the mod_rewrite to handle paths ? Can this be why an AngularJS file is not being loaded ? (36 Replies)
Discussion started by: MaxtheCat
36 Replies

2. Web Development

Mod_rewrite - URL rewrite based upon HTTP_REFERER

Hello, I have added following rewrite cond and rewrite rules but it does not work. RewriteCond %{HTTP_REFERER} ^http://192\.168\.1\.150/categories/.*$ RewriteRule ^(.*)$ http://www.blahblah.com/ When I hit url : http://192.168.1.150/categories/881-Goes?page=7 in my browser - it... (2 Replies)
Discussion started by: ashokvpp
2 Replies

3. UNIX for Advanced & Expert Users

Apache Mod_rewrite Mystery

Hi Folks, I am running on a CentOS 6.3 server, whose primary function until recently has been my Zimbra mail server exclusively. I added wordpress and I have not been disappointed, with this one exception of Apache mod_rewrite. I have already tried to set selinux to permisive to eliminate that... (5 Replies)
Discussion started by: cjm51213
5 Replies

4. Web Development

Mod_rewrite http to https

Hi Team, I have a question on the apache mod_rewrite module. I have a requirement of rewriting only specific url's to https. Requirement below:- want to match a word (test) on the url and if matches then it should rewrite to https. example:- ... (1 Reply)
Discussion started by: arumon
1 Replies

5. Shell Programming and Scripting

help with wget and 404 errors

I am trying to use wget to make a local copy of this website accuscore.com/fantasy-sports/nfl-fantasy-sports/Current-Week-DEF-ST (i have the http:// in front, but the forum will not allow me to put it in at this time) Whenever i try to use wget i receive an "Error 404: Not found". I tried the... (4 Replies)
Discussion started by: problemss
4 Replies

6. Shell Programming and Scripting

Need help with mod_rewrite rule, redirect

I have to redirect http://www.domain.com/(*)/(*)-hotel-deals.html to http://www.domain.com/(*)/(*)-hotel-deals where of course (*) are dynamic. Any ideas how this could be accomplished? (0 Replies)
Discussion started by: EXT3FSCK
0 Replies

7. Web Development

Apache mod_rewrite: from 'friendly' url to actual path

I'd like to translate a friendly url such as: http://www.xxxyyyzzz.com/page/12345678/ to: http://www.xxxyyyzzz.com/page/12/34/56/78/ Seems simple enough, but I cannot figure out how. Any one done this before? (2 Replies)
Discussion started by: markericksen
2 Replies

8. Web Development

mod_rewrite help

Here's my situation. When a user access the site domain.com it redirects to /portal which displays SKIN1 by default. When a user accesses the site domain.com/portal?branding=SKIN1 it displays SKIN1 by default as well. When a user access the site domain.com/portal?branding=SKIN2 it... (0 Replies)
Discussion started by: Adrnalnrsh
0 Replies

9. Shell Programming and Scripting

mod_rewrite problem

hi i'm very new to mod_rewrite. I can't seem to have this work. I have a site which has 4 pages : home, links, adverts and contacts page. the adverts page is linked to this url http://www.xxxxxx.com/adverts.php. What i want is that whenever the adverts page is clicked , it will show... (0 Replies)
Discussion started by: arsonist
0 Replies
Login or Register to Ask a Question