Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 01-28-2010, 06:58 PM 301 on Apache Server
Average Talker

Posts: 16
Name: John
Trades: 0
Hello to everyone,

I am all new to this sorry in advance if I do not make sence.................

I had my sites mark up which was built in tables built in php and the php was redircted to the .html extensions of the live site thats been live for a while i did not want to change the urls.

I need to 301 redirect the .php to the .html I added the some code to the .htaccess file and it has 301 redirected the

1, non www. to the www.

2, index.html and index.php to /

And the php extensions to html are still working but no matter what i do i cant seem to 301 the .php to the .html

Site name being www domain co uk

================================================== ==========

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^domain\.co.uk [NC]
RewriteRule (.*) http://www.domain.co.uk/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://www.domain.co.uk/$1 [R=301,L]

# rewrite php extensions to html

RewriteCond %{SCRIPT_FILENAME} -f [OR]
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule .* - [L]

RewriteRule ^([^/]*).html$ $1.php

================================================== =========


I would be very very greatful for any help recivied, spend two days reading here and there and no luck yet.

Thank you.

Last edited by jim111; 01-28-2010 at 07:04 PM..
jim111 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-28-2010, 07:33 PM Re: 301 on Apache Server
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Explain again why you need to rewrite the file extensions??
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-28-2010, 08:02 PM Re: 301 on Apache Server
Average Talker

Posts: 16
Name: John
Trades: 0
Hi chrishirst,

Thank you very much for your reply.........................

The old sites urls were say like this www.domain.co.uk/page1.html

The web desginer built the new mark up in php and added the below code to the .htaccess file.............

I told them i did not want the urls to change

================================================== ======
Options +FollowSymLinks
RewriteEngine On

# rewrite php extensions to html

RewriteCond %{SCRIPT_FILENAME} -f [OR]
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule .* - [L]

RewriteRule ^([^/]*).html$ $1.php

================================================== ======

I then added the below code

================================================== =======

RewriteCond %{HTTP_HOST} ^domain\.co.uk [NC]
RewriteRule (.*) http://www.domain.co.uk/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://www.domain.co.uk/$1 [R=301,L]

================================================== ========

I have never done 301 redirects that include php like this,

thanks
jim111 is offline
Reply With Quote
View Public Profile
 
Old 01-29-2010, 07:22 AM Re: 301 on Apache Server
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Why not just keep the .html extensions and set the server to parse .html as php?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-29-2010, 08:02 AM Re: 301 on Apache Server
Average Talker

Posts: 16
Name: John
Trades: 0
Hi chrishirst,

I am very grateful for your reply........

This is stuff I have no idea about sorry for my ignorance on this..........

I don’t understand your reply as I not good with type of stuff,

If the site is uploaded on to different servers without the below code in the .htaccess file the site can only be see with the .php extension in the url you can see the correct urls with the .html
extension chrishirst......

I would be very grateful if you could this once explain in baby terms so I get it please

[CODE]Options +FollowSymLinks
RewriteEngine On

# rewrite php extensions to html

RewriteCond %{SCRIPT_FILENAME} -f [OR]
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule .* - [L]

RewriteRule ^([^/]*).html$ $1.php[/CODE



----------------------------------------------------------------------------------------------------------

Last edited by jim111; 01-29-2010 at 08:05 AM..
jim111 is offline
Reply With Quote
View Public Profile
 
Old 01-29-2010, 08:22 AM Re: 301 on Apache Server
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Add this
Code:
AddType text/html .htm .html
AddHandler application/x-httpd-php .htm .html
Options Indexes FollowSymLinks Includes
To your .htaccess and .htm & .html pages will be parsed as PHP

NO redirects needed, no need for URIs to change.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-29-2010, 10:07 AM Re: 301 on Apache Server
Average Talker

Posts: 16
Name: John
Trades: 0
Hi chrishirst,

Thank you for your time...........

The live site urls end with .html and thats what I need to show on the site

Correct url = www.mysite/contact.html

In correct url = www.mysite/contact.php

I tryed to code but no joy chrishirst.......

I would be very greatful if you could post back please with your thought ,

Thank you
jim111 is offline
Reply With Quote
View Public Profile
 
Old 01-29-2010, 10:43 AM Re: 301 on Apache Server
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
"no joy" means what exactly?


Can we have a real URI?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-29-2010, 11:04 AM Re: 301 on Apache Server
Average Talker

Posts: 16
Name: John
Trades: 0
Hi sorry,

I uploaded a copy on a testing server with the below code

Code:
AddType text/html .htm .html
AddHandler application/x-httpd-php .htm .html
Options Indexes FollowSymLinks Includes
in the .htaccess file

The site could be seen when using the .php urls but not for the .html urls............

Very sorry chrishirst did not check my writing, sorry..........

Last edited by jim111; 01-29-2010 at 12:56 PM..
jim111 is offline
Reply With Quote
View Public Profile
 
Old 01-29-2010, 11:27 AM Re: 301 on Apache Server
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
in the .htaccess file and the could been with searching for the .html urls

But could be seen when searching for the .php urls
Could you repeat that in English please??
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-29-2010, 12:49 PM Re: 301 on Apache Server
Average Talker

Posts: 16
Name: John
Trades: 0
Very sorry I edited the above post, so it can be read :-)
jim111 is offline
Reply With Quote
View Public Profile
 
Old 01-29-2010, 01:09 PM Re: 301 on Apache Server
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
The code I gave does NOT redirect HTML to PHP it means you can PUT php code in html pages snd it will run the code
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-29-2010, 02:21 PM Re: 301 on Apache Server
Average Talker

Posts: 16
Name: John
Trades: 0
Hi chrishirst,

Sorry if I am not making sense here..........

The new pages are php files and in php (I’m think you got this from what I have said, just making sure as I not sure how to explain it very well sorry)

I made a new .htaccess file added the code you gave into it and uploaded it to the live site and it returned a server error when I search for the site so I uploaded the other .htaccess file again.......

So still not sure what to do?

Sorry for being a pain in the butt
jim111 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to 301 on Apache Server
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.36277 seconds with 12 queries