Forum Moderators: phranque
example.com/go/1 looks much better than example.com/go/index.php?ID=1 (it's a small url... whit bigger URL you will see better)
I don't really know how to explain (don't know the words in english)
How do I do that in apache? htaccess? CGI?
MrHaan
Srry for bad English
this is my .htaccess in my root directory
Options -Indexes
# Enable mod_rewrite, start rewrite engine
Options +FollowSymLinks
RewriteEngine on
#
# Internally rewrite search engine friendly static URL to dynamic filepath and query
RewriteRule ^go/([^/]+)/?$ go/index.php?ID=$1 [L]
#
# Externally redirect client requests for old dynamic URLs to equivalent new static URLs
RewriteCond %{THE_REQUEST} ^[A-Z]{2,9}\ /index\.php\?ID=([^\ ]+)\ HTTP/
RewriteRule ^index\.php$ http://example.com/go/%1? [R=301,L]
"go is the subdir where the script is"
MrHaan
Edit: I seems I have It working again...(only wrong para meter passed to the script)
I get index.php when I "echo" PHP global variable $_GET["ID"] not the number...
<snip>
[edited by: MrHaan at 9:47 pm (utc) on May 1, 2009]
# Internally rewrite search engine friendly static URL to dynamic filepath and query
RewriteCond $1 !^index\.php$
RewriteRule ^go/([^/]+)/?$ go/index.php?ID=$1 [L]
In order to redirect direct client requests for URL example.com/go/index.php?ID=1 to URL example.com/go/1, you will need to add another rule, also discussed in the thread I cited above (described as optional step 3). This new rule will capture a client request for the dynamic URL and redirect it to the static URL. This is a URL-to-URL translation, termed an "external redirect," and involves sending an HTTP response to the client that says, "The resource that you have requested has moved. Please ask for it again at this new URL."
This may be clearer if you understand that mod_rewrite works as a client's HTTP request arrives at your server, and translates the client's incoming URL request to either an internal filepath (rewrite) or to another URL (redirect). This takes place before any content is served or any scripts are invoked.
Jim