Welcome to WebmasterWorld Guest from 54.167.0.111

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

mod_rewrite "emergency"

dmoz directory "typo" is going to non-existing folder

     

amznVibe

4:18 pm on Jan 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member


Normally I would sit down and make this a learning project
but its a bit of an emergency so I need someone's expertise

I just noticed a site I am responsible for got into DMOZ but its got the wrong URL -
pointing to a non-exisiting folder without any file name! (sheesh DMOZ editors)

this code doesn't work to fix it, any pointers?

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.Ķ )\.mydomain\.com/blah$
RewriteRule ^(.*)$ http://www\.mydomain\.com/new-blah\.htm$1 [L]

gingerbreadman

4:23 pm on Jan 13, 2003 (gmt 0)

10+ Year Member



Try this...

[httpd.apache.org...]

Might be some help.

john316

4:37 pm on Jan 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you don't have time for the learning curve, why not just create the directory and file?

andreasfriedrich

4:44 pm on Jan 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



%{HTTP_HOST}
contains only the host that should handle the request, i.e. www.domain.tld or domain.tld or whatever. Unless there is somethink tricky going on like using mod_rewrite to handle subdomains you usually do not need to test for that. Rewriting takes place after Apache has determined which host/virtual host should handle the request.

The syntax for the RewriteRule is

RewriteRule re-matching-URI-path rewritten-URI
.

There is no need to escape dots in the

rewritten-URI
part since it is not a regular expression, i.e. the dot has no special meaning.

If the link is DMOZ is [domain.tld...] and you want it rewritten to [domain.tld...] then your RewriteRule would need to look something like this.

RewriteRule ^aaron/$ [domain.tld...]  [L,R=301]

You could use the much simpler Redirect [httpd.apache.org]Permanent as well:

RedirectPermanent /aaron [domain.tld ]

Please read An Introduction to Redirecting URLs on an Apache Server [webmasterworld.com] by DaveAtIFG if you havenīt done so yet. We are generally ask not to supply code like this. I made an exception this time. But please be sure to read the introduction and study the mod_rewrite docs. Testing and playing around on a local server will help a lot. Apache is very easy to set up on almost all operating systems.

Andreas

amznVibe

6:23 pm on Jan 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thank you for the help. It's working perfectly now.

I promise by the end of the day to have read all the
mod_rewrite stuff so I don't re-hash easier stuff like this.
I've got a whole new bookmark folder for mod_rewrite
now and will be reading and practicing shortly :)

Been meaning to do that for awhile now but you know
how little projects get pushed aside when bills have
to be paid. But mod_rewrite is one super serious tool
and I just need to make it a priority to master it.

Thanks again! (what are we up to, 3 pints of cider? :) )

andreasfriedrich

10:45 pm on Jan 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You are welcome amznVibe. I figured the rule against posting specific rules applied only when answering posts of people who otherwise do not contribute to WebmasterWorld.

Andreas

 

Featured Threads

Hot Threads This Week

Hot Threads This Month