Question

Could someone point me in the right direction? I'm trying to create a url like the one below. I don't want to use url hashes #I2QT40oSwU0AoH7g02cAHI or parameters ?myparam=I2QT40oSwU0AoH7g02cAHI.

https://www.dropbox.com/l/I2QT40oSwU0AoH7g02cAHI

Is this done with mod_rewrite?

Many thanks!

Was it helpful?

Solution

Yes, it's done by editing the httpd.conf file (turn on AllowOverride all) and creating a .htaccess file in your root web directory.

Here is a sample .htaccess file

Options -Multiviews

RewriteEngine On
RewriteBase /

RewriteRule ^l/(.*)$ /somescript.php?key=$1 [L]

The above will direct

https://www.dropbox.com/l/I2QT40oSwU0AoH7g02cAHI

to

https://www.dropbox.com/somescript.php?key=I2QT40oSwU0AoH7g02cAHI

OTHER TIPS

It's called Clean URL Usually it's implemented via url rewrite technique. But also you can use 404 HTTP error page to handle such urls.

Yes it is! A mod rewrite is exactly what you are looking for. You can play around with this generator here: http://www.generateit.net/mod-rewrite/index.php

Here is the solution:

Put a .htaccess in your root, add this to it. When the user enters

http://domain.com/l/I2QT40oSwU0AoH7g02cAHI

it will execute this "hidden" on the server

http://domain.com/index.php?myparam=I2QT40oSwU0AoH7g02cAHI

Add this:

RewriteEngine On

# /l/ trick
RewriteRule ^l/([^/]*)$ /index.php?myparam=$1 [L]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top