Forum Moderators: phranque
I am new to this .htaccess rewriting and have a simple problem. I want to redirect my index.html page in the root directory to my index.php page in a sub directory. So my site would be http:www.mydomain.com/index.html and my new homepage would be situated at [mydomain.com...]
Is there a simple command I can use in .htaccess that would redirect them to my index.php page?
Thanks in advance.
TD
Another thing I noticed that when it does redirect it takes out the www prefix in the url.
So it redirects to [domain.com...]
I'm doing this through CPanel. It was my hosts that reccomended using .htaccess.
Are they useless or am I just missing something?
Thanks
TD
Heres what it was putting over when I changed it in CPanel:
RewriteEngine on
RewriteRule ^index/.html$ /zen/index.php
RedirectMatch permanent ^/index.html$ [domain.com...]
Obviously in the URL I just add the www prefix in .htaccess and uploaded.
This brings me to another question although I don't think this is the place for it, if not I apologise.
I have optimised my site and all inbound links are pointing to the raw URL [domain.com....] Redirecting this URL to [domain.com...] will it effect the optimisation on the site for my new homepage? I mean, would I have to optimise my new homepage all over again or would the search engines treat the new page as my old page and I can carry on regardless?
Also, will this pass over the current PR4 of the sites old homepage?
Thanks for the replies, much appreciated.
TD
This "exposes" your internal site structure to users and the search engines. For the search engines, the redirect tells them to purge the old URL and start using the new one. For SEO purposes, that's not really desirable.
Given the small 'view' I have of your site from the code snippets you've posted, something like this might work better for you:
RewriteEngine on
# Redirect non-www to www domain
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#
# Rewrite index.html requests to /zen/index.php
RewriteRule ^index/.html$ /zen/index.php [L]
#
# -alternate version- commented-out
# This would rewrite requests for [i]either[/i] "/index.html" or just "/" to the /zen index.php file.
# RewriteRule ^(index/.html)?$ /zen/index.php [L]
An alternative is to rewrite all image requests as well as page requests, so that changing the page code won't be required. This is possible if the site is highly-organized and the image URLs that need to be rewritten can be easily identified. It won't work well/easily/efficiently if you have images scattered all over the server's filespace. ...Anyway, something to consider.
Jim
Unfortunatly I use Zen Cart which is template/CSS driven so its going to take some altering. All of the images are pointing to /images rather than [domain.com...] and there are many, many spacers.
Thanks again.
TD