/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] header issue

I want to remove the index.php file extension, but what i do below doesn’t work.

if($_SERVER[‘HTTP_REFERER’]) == “www.domain.com/index.php”)
header(“Location: www.domain.com”);

This brings me back to [url]www.domain.com/index.php[/url]

How can I fix this?

Thanks

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@scragarFeb 26.2009 — What? If you come from the index page send you back to the first page?

I think it might be easier to just never use index.php in your code, / works fine for that purpose.
Copy linkTweet thisAlerts:
@sc_kingauthorFeb 26.2009 — I would like to avoid using index.php for my main page.

But search engines pick up both http://www.domain.com and http://www.domain.com/index.php

I want http://www.domain.com/index.php to go to http://www.domain.com

but when i use header("Location: http://www.domain.com"); it doesn't take away the /index.php
Copy linkTweet thisAlerts:
@scragarFeb 26.2009 — [code=php]if($_SERVER['REQUEST_URI'] == 'index.php'){
header('Location: /');
exit;
};[/code]

Try that.
Copy linkTweet thisAlerts:
@sc_kingauthorFeb 26.2009 — Yes that worked, thanks!
×

Success!

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

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

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