Welcome to WebmasterWorld Guest from 54.167.102.69

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

mod_rewrite "emergency"

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

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 16, 2002
posts:2010
votes: 0

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]

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

Junior Member

10+ Year Member

joined:Jan 3, 2003
posts:83
votes: 0


Try this...

[httpd.apache.org...]

Might be some help.

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 3, 2001
posts:1609
votes: 0


If you don't have time for the learning curve, why not just create the directory and file?
4:44 pm on Jan 13, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 22, 2002
posts:1782
votes: 0


%{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

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 16, 2002
posts:2010
votes: 0


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? :) )

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 22, 2002
posts:1782
votes: 0


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

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members