This .htaccess throws me a 500 error. I've Googled/tried everything.

RewriteEngine on
RewriteRule ^([0-9]{6})$ decode.php?shorturl=$1 [L]

It's for a URL shortener. I am new to this stuff.

Recommended Answers

What URL are you expecting from your links and users? e.g. http://www.example.com/123456 ?

rewriting usually gets the better of me too. Have you checked the error log? Typically at:

apache/logs/error.log

Jump to Post

Why not just change decode.php to index.php?

Like:

RewriteEngine On
RewriteRule ^([0-9]{6})$ /index.php?shorturl=$1 [L]
Jump to Post

Did you check your logs?

//EDIT

This works fine for me:

RewriteEngine On
RewriteRule ^([0-9]{6})$ /product.php?shorturl=$1 [L]

Then in my product.php page:

<?php echo (isset($_GET['shorturl'])) ? 'ShortUrl: ' . $_GET['shorturl'] : 'No short url' ;?>

Which when I enter the address: www.example.com/123456 (not lierally - just my testing …

Jump to Post

All 9 Replies

Member Avatar

What URL are you expecting from your links and users? e.g. http://www.example.com/123456 ?

rewriting usually gets the better of me too. Have you checked the error log? Typically at:

apache/logs/error.log

Member Avatar

Why not just change decode.php to index.php?

Like:

RewriteEngine On
RewriteRule ^([0-9]{6})$ /index.php?shorturl=$1 [L]
Member Avatar

Did you check your logs?

//EDIT

This works fine for me:

RewriteEngine On
RewriteRule ^([0-9]{6})$ /product.php?shorturl=$1 [L]

Then in my product.php page:

<?php echo (isset($_GET['shorturl'])) ? 'ShortUrl: ' . $_GET['shorturl'] : 'No short url' ;?>

Which when I enter the address: www.example.com/123456 (not lierally - just my testing site) gives me the output:

ShortUrl: 123456

Well, that gives me a 500 error. There's nothing special in the logs.

Member Avatar

OK, sorry, I can't reproduce the error. Anybody else?

Well, I solved it. I did not have the mod_rewrite module installed.

Member Avatar

Doh! Thanks for sharing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.