.htaccess code ?
-
What is the code to redirect
www.xyz.com/abc where abc is a folder to www.xyz.com/abc.html
-
Hey Atul
There is a really good cheat sheet here:
http://www.addedbytes.com/cheat-sheets/mod_rewrite-cheat-sheet/
It shows you the most common things you will need to do and is certainly worth printing off and super glueing to the wall next to your desk.
So, looking at the sheet (and you really have to learn this stuff rather than luck it through else you will end up going around the bend when something does not work as you want it to) a basic rewrite works as follows:
RewriteRule ^page.html$ new_page.html [R=301,NC,L]
So, to make this work for you
RewriteRule ^page.html$ new_page.html [R=301,NC,L]
But, that is, assuming I understood your question and you are actually looking to redirect A to B and not to just create a nicer URL by masking the /abc/ as /abc.html in which case this is the basics for creating a pretty URL
RewriteRule ^([A-Za-z0-9-]+)/?$ categories.php?name=$1 [L]
- that is for a more dynamic page with a querystring but the theory is the same.
Maybe if you provided an exact example I can give you one example to build on?
Hope it helps!
Marcus
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
-
Does the coding of a website really what matter for SEO
Hello, Just wondering if a site that is not coded correctly can hurt your seo even though as a human I can totally understand what is going on on the page and the structure of the website. Thanks,
Intermediate & Advanced SEO | | seoanalytics0 -
Hacked website - Dealing with 301 redirects and a large .htaccess file
One of my client's websites was recently hacked and I've been dealing with the after effects of it. The website is now clean of malware and I already appealed to Google about the malware issue. The current issue I have is dealing with the 20, 000+ crawl errors which are garbage links that were created from the hacking. How does one go about dealing with all the 301 redirects I need to create for all the 404 crawl errors? I'm already noticing an increased load time on the website due to having a rather large .htaccess file with a couple thousand 301 redirects done already which I fear will result in my client's website performance and SEO performance taking a hit as well.
Intermediate & Advanced SEO | | FPK0 -
Htaccess or url rewrite module for Magento 301 redirects?
I need to do about 6000 redirects for a Magento site. The pages no longer exist. I have tried the URL rewrite module but it isn't working for me and I don't want to do 6000 redirects in the htaccess files. Any suggestions?
Intermediate & Advanced SEO | | Tylerj0 -
How important is my code to text ratio on web pages?
I've been getting mixed reviews on this and I'm trying to figure out whether this is something I should be concerned with. We have a higher than recommended amount of code, relative to "content" but not by a crazy amount. Thanks!
Intermediate & Advanced SEO | | absoauto0 -
Questions about websites coupon codes
Hi guys, i have 2 questions about my website of coupon codes: should i do redirect people of google to mywebsite, e.g. Someone is looking coupons for Sony or LG and arrive to brand Sony in my website but i show him offers for Sony in Amazon when he click in some offer, ¿that is correct? Footer images links. I saw many sites that put their logos in footer of online stores to get authority, ¿should i do that? Thank you so much.
Intermediate & Advanced SEO | | pompero990 -
.htaccess files
I am working with a clients website which has multiple htaccess files (.htaccess , .htaccess.holiding, and .htaccess.live -all in the same directory) My question is how does a server process these files? All 3 files? Currently the domain has 301 redirect showing for the home page to the mobile site (which is a problem) in one of the files (.htaccess but not others) Has anyone come across this before with regard to SEO problems?
Intermediate & Advanced SEO | | OnlineAssetPartners0 -
How does one know where to insert the right strips of coding on the right pages for Canonical Links?
On my Website, I am the only SEO optimizer wizard person. I have to teach myself everything and I get overwhelmed a lot. I recently started using SEOMOZ and on my report it stated we had duplicate page titles and that it was bad and should be fixed quickly. So I did my research and found that I needed to use canonical links to reference one page to be indexed. However my problem lies in exactly how to add this coding to my site. I greatly appreciate any help or at least looking at this question.
Intermediate & Advanced SEO | | FrontlineMobility0 -
Googlebot HTTP 204 Status Code Handling?
If a user runs a search that returns no results, and the server returns a 204 (No Content), will Googlebot treat that as the rough equivalent of a 404 or a noindex? If not, then it seems one would want to noindex the page to avoid low quality penalties, but that might require more back and forth with the server, which isn't ideal. Kurus
Intermediate & Advanced SEO | | kurus0