Hi anyone please help I use this code but now getting 404 error. please help.
-
#index redirect
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.html\ HTTP/
RewriteRule ^index.html$ http://domain.com/ [R=301,L]
RewriteCond %{THE_REQUEST} .html
RewriteRule ^(.*).html$ /$1 [R=301,L]hi anyone please help I use this code but now getting 404 error. please help.
homepage and service.html page is working, but the rest pages like about.html, servicearea.html, and contact.html is not working showing 404 error.
and also when you type this URL. generalapplianceserice.ca/about.html
generalapplianceserice.ca/contact.html
generalapplianceserice.ca/servicearea.html
it automatically remove the .HTML extension and shows 404 error, the pages name in root directory is same.
these pages work like generalapplianceservice.ca and generalapplianceservice.ca/services
why?
i also remove this code again but still same issue.
-
It seems like you're experiencing issues with URL redirection and page access in your website's .htaccess file. Let's break down the problem and address it step by step.
-
URL Redirection for index.html
Your code snippet seems to be redirecting requests forindex.html
to the root domain. This part of the code looks fine and shouldn't be causing any 404 errors. -
Removing .html Extension
The second part of your code is meant to remove the .html extension from URLs. However, it seems to be causing the 404 errors for pages likeabout.html
,contact.html
, andservicearea.html
. -
Troubleshooting
Here are a few things you can check and try to resolve the issue:- Ensure that the .htaccess file is placed in the root directory of your website.
- Verify that mod_rewrite is enabled on your server.
- Check file permissions to ensure that the .htaccess file is readable by the server.
- Make sure that the pages
about.html
,contact.html
, andservicearea.html
exist in the root directory of your website. - Verify that the file names are spelled correctly and match the URLs you're trying to access.
-
Alternative Approach
If you're still encountering issues, you might consider an alternative approach to removing the .html extension. Instead of using mod_rewrite rules, you can configure your web server (e.g., Apache) to handle URL rewriting.For example, in Apache, you can use the following configuration in your virtual host or server configuration file:
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.html -f RewriteRule ^(.*)$ $1.html [NC,L] </IfModule>
This configuration will serve requests without the .html extension if the corresponding .html file exists in the root directory.
-
Testing
After making any changes, be sure to clear your browser cache and test the URLs again to see if the issue has been resolved. -
Further Assistance
If you're still having trouble, you may need to provide more details about your server environment (e.g., Apache version, hosting provider) for further assistance. Additionally, consulting your hosting provider's support team or a web development professional could also be beneficial in resolving the issue.
Suppose you have the following files in the root directory of your website:
index.html
about.html
contact.html
servicearea.html
And you want to remove the .html extension from URLs while ensuring that the pages are accessible without it.
Ensure .htaccess file exists: First, make sure you have an .htaccess file in the root directory of your website.
Enable mod_rewrite: Check if mod_rewrite is enabled on your server. You can do this by creating a PHP file (e.g., info.php) with the following content:
php
<?php
phpinfo();
?>
Access this file through your web browser (e.g., https://installationandrepairs.com/info.php) and search for "mod_rewrite". If it's enabled, you should see it listed.
Edit .htaccess file: Open your .htaccess file and add the following code:
apache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html [NC,L]
</IfModule>Testing: Once you've made the changes, clear your browser cache and test the URLs without the .html extension. For example:
https://installationandrepairs.com/ should display the index.html page.
https://installationandrepairs.com/about should display the about.html page.
https://installationandrepairs.com/contact should display the contact.html page.
https://installationandrepairs.com/servicearea should display the servicearea.html page.
If everything is configured correctly, you should be able to access your pages without the .html extension, and you shouldn't encounter any 404 errors.
Remember to remove the info.php file after you've checked if mod_rewrite is enabled, as it may contain sensitive information about your server configuration. Additionally, always keep backups of your files before making changes to your website's configuration. -
-
Thank you guys, for your help it helped my problem to slove. I restore my pages back.
-
In addition to the advice and tips you have already received here (in general: be super careful with .htaccess / httpd.conf files, and revert to previous versions if you see unexpected behaviour) one additional tip is to consider turning on logging while you debug the problem.
-
Carefull with what your doing. I think you should revert in the first place if your not setting up a 301 moved status. Because of that, you could lose the (indexed) rankings for your index.html page. What you can do is a manual redirect, i.e
redirect 301 /index.html /
This moves (including the ranks) the index.html page back to / the root of your domain. You could also setup a canonical URL > https://moz.com/learn/seo/canonicalization
-
hi, thanks for your reply, Jeroen, I was trying to remove the content duplication, that occurred
when I was crawling my website with the Moz pro tool.
its showed me two pages, generalapplianceservice.ca, and generalapplianceservice.ca/index.html
I was just trying to remove the index.html page.
so I used the above code. and start getting an error of 404, in 3 to 4 pages of the website. the pages were correct in the root page, the name of pages was also correct.
the page was this generalapplianceserice.ca/about.html, before the code and after the code, it removed the generalapplianceserice.ca/about
.HTML extension from the URL and showing a 404 error.
right now I used Errordocument 404 code in htaccess file. for handling 404 pages.
also the change the page name. but I need the same page back.
any help?
-
Could you tell us what you are trying to archieve in the first place? Your script proberly wont work, because domain.com is'nt replaced with your own domain, second it's code is only valid for HTTP instead of https, so to work with what we have here, try this:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.html\ HTTP/
RewriteRule ^index.html$ https://generalapplianceservice.ca/ [R=301,L]
RewriteCond %{THE_REQUEST} .html
RewriteRule ^(.*).html$ /$1 [R=301,L]
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Privacy: Is Whois info used to help establish an admin relationship between sites in addition to host/IP etc ?
Hi Do you think Google looks at WhoIs details as a contributing factor to establishing an adminsitrative relationship between two domains (in addition to being hosted on similar hosts/IP blocks etc), and in regard to linkbuilding would having teh same whois details on both sites have a negative effect or be perfectly ok (if the sites are on different hosts/ip blocks) ? Also do you think whois privacy turned on has a negative effect on trust and subsequent seo ? Considering the answer to the above two questions: Do you think its a good or bad idea to have domain reg/whois ‘privacy’ turned on for a site of curated content relating to the project/primary sites niche, and linking to this site for contextual link benefit ? Im building out a site of curated content that i want to perform well in-itself as well as providing backlink benefit to the primary site but worried if they both have same whois details will cause seo problems or would that only be if also had same host/ip footprint ? Should i enable whois privacy, use a different address for reg, or actually make a point of using the same whois details for transparency ? All Best
Technical SEO | | Dan-Lawrence
Dan0 -
A few pages deindexed from Google .. PLEASE HELP!
My client has a fairly new site and we were agressively building content to the website. It is an ecommerce store and we have got a blog as well. We guest blogged in a few places and wrote 3-5 articles a day. Last few days, i noticed 3-4 pages that we were building links to got deindexed. What could be the reason? We weren't using any bots to build links, only a couple of it around 5-10 links to a page. Google WMT is not showing any messages and no manual action is seen. What could be the reason? I've submitted those URL for reindex and so far nothing seems to work. Any idea? Please help.
Technical SEO | | WayneRooney0 -
Many Errors on E-commerce website mainly Duplicate Content - Advice needed please!
Hi Mozzers, I would need some advice on how to tackle one of my client’s websites. We have just started doing SEO for them and after moz crawled the e-commerce it has detected: 36 329 Errors – 37496 warnings and 2589 Notices all going up! Most of the errors are due to duplicate titles and page content but I cannot identify where the duplicate pages come from, these are the links moz detected of the Duplicate pages (unfortunately I cannot add the website for confidentiality reasons) : • www.thewebsite.com/index.php?dispatch=categories.view&category_id=233&products_per_00&products_per_2&products_per_2&products_per_2&page=2 • www.thewebsite.com/index.php?dispatch=categories.view&category_id=233&products_per_00=&products_per_00&products_per_2&products_per_2&products_per_2&page=2 • www.thewebsite.com/index.php?dispatch=categories.view&category_id=233&products_per_00=&products_per_00&products_per_2&page=2 • www.thewebsite.com/index.php?dispatch=categories.view&category_id=233&products_per_2=&products_per_00&page=2 • www.thewebsite.com/index.php?dispatch=categories.view&category_id=233&products_per_00&products_per_00&products_per_00&products_per_00&page=2 With these URLs it is quite hard to identify which pages need to be canonicalize. And this is jsut an example out of thousands on this website. If anyone would have any advice on how to fix this and how to tackle 37496 errors on a website like this that would be great. Thank you for your time, Lyam
Technical SEO | | AlphaDigital0 -
Does anyone use inspect firebug for their site
Hi, i am using wordpress for the first time, i normally use joomla, but now i have been recommend to use inspect firebug to help me sort problems on my site which includes the title of the home page, www.cheapflightsgatwick.com being called - lanzarote reviews - cheap flights gatwick but it should say cheap flights reviews magazine The problem i have with firebug is understanding what it is telling me and where things are, i would like to know if anyone uses this product and if so how easy or hard have they found using it
Technical SEO | | ClaireH-1848860 -
Errors - 7300 - Duplicate Page Content..Help me..
Hi, I just received the crawl report with 7300 errors of duplicate page content. Site built using php. list of errors will be like this.. http://xxxxx.com/channels/ http://xxxxx.com/channels/?page=1 http://xxxxxx.com/channels/?page=2 I am not good in coding and using readymade script for this website. could anyone guide me to fix this issue? Thanks.
Technical SEO | | vilambara0 -
Duplicate content issues, I am running into challenges and am looking for suggestions for solutions. Please help.
So I have a number of pages on my real estate site that display the same listings, even when parsed down by specific features and don't want these to come across as duplicate content pages. Here are a few examples: http://luxuryhomehunt.com/homes-for-sale/lake-mary/hanover-woods.html?feature=waterfront http://luxuryhomehunt.com/homes-for-sale/lake-mary/hanover-woods.html This happens to be a waterfront community so all the homes are located along the waterfront. I can use a canonical tag, but I not every community is like this and I want the parsed down feature pages to get index. Here is another example that is a little different: http://luxuryhomehunt.com/homes-for-sale/winter-park/bear-gully-bay.html http://luxuryhomehunt.com/homes-for-sale/winter-park/bear-gully-bay.html?feature=without-pool http://luxuryhomehunt.com/homes-for-sale/winter-park/bear-gully-bay.html?feature=4-bedrooms http://luxuryhomehunt.com/homes-for-sale/winter-park/bear-gully-bay.html?feature=waterfront So all the listings in this community happen to have 4 bedrooms, no pool, and are waterfront. Meaning that they display for each of the parsed down categories. I can possible set something that if the listings = same then use canonical of main page url, but in the next case its not so simple. So in this next neighborhood there are 48 total listings as seen at: http://luxuryhomehunt.com/homes-for-sale/windermere/isleworth.html and being that it is a higher end neighborhood, 47 of the 48 listings are considered "traditional listings" and while it is not exactly all of them it is 99%. Any recommendations is appreciated greatly.
Technical SEO | | Jdubin0 -
Mass 404 pages
Hi Guys, If I were to have to take down the majority of my site, taking all content and links pointing to that content down. How would the search engines react? Would I get a penalty for the majority of the site all of the sudden missing? My only concern is the loss of traffic on the remanding pages. Thanks!
Technical SEO | | DPASeo0 -
Duplicate Content Errors
Ok, old fat client developer new at SEO so I apologize if this is obvious. I have 4 errors in one of my campaigns. two are duplicate content and two are duplicate title. Here is the duplicate title error Rare Currency And Old Paper Money Values and Information.
Technical SEO | | Banknotes
http://www.antiquebanknotes.com/ Rare Currency And Old Paper Money Values and Information.
http://www.antiquebanknotes.com/Default.aspx So, my question is... What do I need to do to make this right? They are the same page. in my page load for default.aspx I have this: this.Title = "Rare Currency And Old Paper Money Values and Information."; And it occurs only once...0