/    Sign up×
Community /Pin to ProfileBookmark

mod_rewrite – news headlines

Hi there,

Applogies in advance if this has already been posted, I did a search but couldnt see anything.

I’ve been set the task to boost one of our clients’ websites in Google. I have had a play about with mod_rewrite by making most of the links SEO friendly.

Now I want to be able to include news headlines that get posted in PHP as a mod_rewrite, something like [url]www.mydomain.com/home/news/News-Headline-Goes-Here[/url]

The source is [url]www.mydomain.com/home/news.php?story=15[/url]

Can someone please point me in the right direction?!

Thanks

to post a comment
SEO

3 Comments(s)

Copy linkTweet thisAlerts:
@websiteideasMar 29.2006 — If you're using a popular CMS or blog script this may be built in already for you. Are you using an open source script? If so, which one?
Copy linkTweet thisAlerts:
@navsterauthorMar 29.2006 — Thanks for the reply.

This site is one we actually designed/CMS'd ourselves. I'm *guessing* that the way to do it is to format the headline in PHP & then tag it onto the end of the query.

Something like news.php?story=15&headline=headline-goes-here

Not sure if I'm in the right ball park here. But then I can use mod_rewrite to format it in the way I want (news/15/headline-goes-here)??

I'm such a novice when it comes to this stuff & the coding completly throws me in the .htaccess file!!
Copy linkTweet thisAlerts:
@_lt_Eddie_gt_Apr 12.2006 — First of all I'll assume you have a .htaccess file setup and placed in the root of your domain. Given the example you posted, what you'll need to do is open the .htaccess file and place the following inside:
<i>
</i>Options +FollowSymLinks
RewriteEngine on
RewriteRule news/(.*)/(.*)/$ /home/news.php?$1=$2
This will allow for the URL to look like:

http://www.mydomain.com/news/story/15/

instead of:

http://www.mydomain.com/home/news.php?story=15

You can even play with this and shorten the URL to make it even more friendly. Say the querystring parameter is always 'story' then you can do the following:

<i>
</i>Options +FollowSymLinks
RewriteEngine on
RewriteRule news/(.*)/$ /home/news.php?story=$1

This will allow for the URL to look like:

http://www.mydomain.com/news/15/

and still redirect to:

http://www.mydomain.com/home/news.php?story=15

Hope that helps...
×

Success!

Help @navster 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 5.17,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

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