View Full Version : mod_write
SilentSpic
02-08-2007, 04:20 PM
<p>Is there a way to change links that contain </p><p>go.php?ID=http://www.ronfez.net</p><p>to read </p><p>links=http://www.ronfez.net </p><p>by using .httaccess? </p><p> </p><p>Thanks</p>
Glück
02-09-2007, 10:38 AM
as in content of a page or the URL?
SilentSpic
02-09-2007, 02:41 PM
as url. When plugging sites it contains the go.php? to keep track of out going hits. I don't like the "?" for SEO purposes. So I would like to mod_write the question mark to something else.
<span class=post_edited>This message was edited by SilentSpic on 2-9-07 @ 6:42 PM</span>
Doctor Z
02-09-2007, 02:52 PM
<img src="http://www.ibiblio.org/koine/greek/lessons/drawgreek.gif" border="0" alt="greek" title="greek" width="241" height="287" />
SilentSpic
02-10-2007, 09:19 AM
<div style="padding-left: 5px"><span class="name"><font face="verdana" size="2" color="#000000"><strong>^^^^ that's extremly helpful!</strong></font></span></div>
SatCam
02-10-2007, 03:41 PM
First off, the name of the apache module you're looking for is mod_rewrite. It's a really cool thing and I jerk off to it at night...
now lets get serious...
first thing you want to do is turn the rewrite engine on...
RewriteEngine on
now you want your actual rule
RewriteRule ^/links=(.+)$ /go.php?ID=$1
The first condition (^links=(.+)$) uses regular expressions (if you're not familiar... <a href="http://www.regular-expressions.info/">regex</a> meet silentspic) to see if the person's url is looking to redirect someone. They can range from fairly simple to difficult and complex. The one I'm using matches any characters, but you can get specific and use one that matches a complete url (http://www. ... .com, etc), but you probably shouldnt bother because you can just do this in the PHP page.
The second condition (go.php?ID=$1) is the actual location of the file they are accessing, that is being masked by the rewritten url. $1 is a variable that represents the URL being given (anything that falls under those parentheses (.+))
So basically, anything after the equals sign (links=<b>...</b>) is being sent to go.php?ID=<b>...</b>. The only difference is, the visitor has no idear. From there on, it's just straight php.
What you need in your .htaccess is:
RewriteEngine On<br />
RewriteRule ^/links=(.+)$ /go.php?ID=$1
There are a ton more features that you can use, but what I gave you should be sufficient. The official extensive documentation is: <a href="http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html">http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html</a>
The catch is... your server must support it. This is no problem if you're hosting it on your own server or you have a virtual server, but I'm assuming since you're using .htaccess that you have shared hosting. You should make sure that you are allowed to use mod_rewrite.
If you can't, don't fret. There's an <a href="http://www.tutorio.com/tutorial/php-alternative-to-mod-rewrite-for-se-friendly-urls">ez php alternative</a> that works without mod_rewrite.
vBulletin® v3.7.0, Copyright ©2000-2024, Jelsoft Enterprises Ltd.