/    Sign up×
Community /Pin to ProfileBookmark

PHP Friendly URLS .htaccess?

Hi I have been totally stumped, I’ve searched and search on this subject and what I have tried hasn’t worked.

Here’s the File:

[code=php]site.com/article.php?foo=23&bar[/code]

I would like to be able to type

[code=php]site.com/article/23/bar[/code]

To access the same article. How do I do that?

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@TJ111Nov 15.2007 — Use [url=http://www.sitepoint.com/article/guide-url-rewriting]mod rewrite[/url]
Copy linkTweet thisAlerts:
@hdoggauthorNov 15.2007 — I've way confused about mod rewrite.... Does it have to be enabled... And do I make those changes in .htaccess?
Copy linkTweet thisAlerts:
@TJ111Nov 15.2007 — The link I posted shows you exactly how to use mod rewrite, even more specifically for PHP pages.
Copy linkTweet thisAlerts:
@hdoggauthorNov 15.2007 — But what if you are on a shared host?
Copy linkTweet thisAlerts:
@TJ111Nov 15.2007 — As long as mod-rewrite is enabled you can do all of it in your .htaccess file. If you can't, contact your host about the possibility of enabling it.
Copy linkTweet thisAlerts:
@hdoggauthorNov 15.2007 — Is that enabled in php.ini?
Copy linkTweet thisAlerts:
@TJ111Nov 15.2007 — No it's in the httpd.conf (apache config file). To test it, make a really simple rewrite rule in your .htaccess and see if it works.
Copy linkTweet thisAlerts:
@hdoggauthorNov 15.2007 — Can .htaccess have as little or as much commands in it? Meaning could i have a blank .htaccess file and add a simple command line and have it work?
Copy linkTweet thisAlerts:
@TJ111Nov 15.2007 — Yep.

[url=http://www.javascriptkit.com/howto/htaccess.shtml]Comprehensive Guide to .htaccess[/url]
Copy linkTweet thisAlerts:
@hdoggauthorNov 15.2007 — Can I put all the mod_write commands in .htaccess?
×

Success!

Help @hdogg 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 6.18,
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: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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