/    Sign up×
Community /Pin to ProfileBookmark

.htaccess question

hi all,

i would like to see my URL like [url]http://myhost.org/id/1/[/url] instead of [url]http://myhost.org?id=1[/url]

can anybody help on this?

thanks in advance

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@jogolApr 17.2007 — [CODE]RewriteEngine on
RewriteRule ^id/([0-9])$ /id/$1/ [R]
RewriteRule ^id/([0-9])/$ /index.php?id=$1
RewriteRule ^id/([0-9][0-9])$ /id/$1/ [R]
RewriteRule ^id/([0-9][0-9])/$ /index.php?id=$1[/CODE]


if you even have 3 digit ids add the following aswell:

[CODE]RewriteRule ^id/([0-9][0-9][0-9])$ /id/$1/ [R]
RewriteRule ^id/([0-9][0-9][0-9])/$ /index.php?id=$1[/CODE]
Copy linkTweet thisAlerts:
@jasonahouleApr 17.2007 — Why not just do it this way? So you don't have to worry about how many digits there are. And if you don't want to redirect the user, then remove the [R]. That way your user still sees the URL as http://myhost.org/id/1/ although they are really at http://myhost.org?id=1
<i>
</i>RewriteEngine on
RewriteRule ^id/([0-9]+)$ /id/$1/ [R]
RewriteRule ^id/([0-9]+)/$ /index.php?id=$1
×

Success!

Help @jeny spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...