Page 1 of 1

URL Shortener, htaccess problem

Posted: Thu Nov 15, 2012 5:03 am
by rabatos
For the URL shortener tutorial I can't seem to get the code in the htaccess file to work.

I entered:
RewriteEngine On

RewriteRule ^([a-z0-9]+)$ go.php?key=$1
and when I enter, http://website.com/2 I just get a 404 error, and am not redirected to the go.php page at all.

Re: URL Shortener, htaccess problem

Posted: Sat Nov 17, 2012 12:19 am
by jacek
Is the file correctly named ? It should be .htaccess with the . at the start.

Re: URL Shortener, htaccess problem

Posted: Sat Nov 17, 2012 11:17 am
by rabatos
Actually I've solved the problem.

The .htaccess file is fine because I've used it before for ErrorDocuments

I found it was a / before go.php I needed like so:

RewriteRule ^([a-z0-9]+)$ /go.php?key=$1 [L]

Re: URL Shortener, htaccess problem

Posted: Tue Nov 20, 2012 12:08 am
by jacek
Ah okay, I probably would not have suggested that so thanks for posting the answer back :D