/    Sign up×
Community /Pin to ProfileBookmark

htaccess rewrite

i dont know if this is suitable for this thread, but i thought i would give it a go.
any ideas on how i can use .htaccess to rewrite a link with letters and underscores into link.php

for example rewrite:

[url]http://domain/link_one[/url]

to:

[url]http://domain/link_one.php[/url]

i spent hours trying to figure it out, and i couldn’t get it. if you have a way please let me know.
thanks,
gil

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@Kostas_ZotosOct 20.2007 — Hi,

I am not familiar with this so maybe i am wrong, but you can try something like this in your .htaccess file:

AddType application/x-httpd-php5 .php

RewriteEngine On

RewriteRule ^YourDomain/([w]+)$ YourDomain/$1.".php"

Or

RewriteRule ^YourDomain/([w]+)$ YourDomain/$1+'.php'

w word => a-zA-Z0-9_

Or use [a-zA-Z_]+ instead of [w]+

(if don't want numbers)
Copy linkTweet thisAlerts:
@bokehOct 20.2007 — Use mod_negociation (+multi views), not mod_rewrite.
×

Success!

Help @giloosh 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.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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