Web Hosting Talk







View Full Version : Rewrite Engine (Again)


Carp
07-12-2006, 07:33 PM
Hey all!

I asked this question before but never really got a clear answer...

I know NOTHING about htaccess

I want to change URL's like mysite.com/123 to mysite.com/link.php?id=123

I don't know how to even put this in .htaccess

I think its something like

RewriteEngine on
RewriteRule something here
RewriteEngine off

???


Thanks alot!

Xigna Hosting
07-12-2006, 08:32 PM
Could you not have Googled:

http://www.google.co.uk/search?hl=en&q=php+.htaccess+search+engine+friendly+URLs&btnG=Google+Search&meta=

Luke

Carp
07-12-2006, 09:01 PM
I looked through alot of those results and didn't find my answer

wolle
07-13-2006, 05:42 AM
How about something like (Beware: untested!):

RewriteRule ^/([0-9]+)$ /link.php?id=$1

It will (hopefully) catch any /<number> request and rewrite it to /link.php?id=<number>

If it does not work you could take a look at:
http://www.sitepoint.com/article/guide-url-rewriting

maxymizer
07-13-2006, 05:56 AM
Rewrite engine works somewhat different with .htacess.
To accomplish what you want, you need this:

RewriteEngine On
RewriteBase /
RewriteRule ^([0-9]+)$ link.php?id=$1 [L]

wolle got it allright, but there's a path issue when using rewrite via .htaccess.

Carp
07-16-2006, 12:06 PM
Finally!!! Thanks maxymizer!!