.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
-
301 Redirects for Multiple Language Sites in htaccess File
Hi everyone, I have a site on a subdomain that has multiple languages set up at the domain level: https://mysite.site.com, https://mysite.site.fr , https://mysite.site.es , https://mysite.site.de , etc. We are migrating to a new subdomain and I am trying to create 301 redirects within the htaccess file, but I am a bit lost on how to do this as it seems you have to go from a relative url to an absolute - which would be fine if I was only doing this for the english site, but I'm not. It doesn't seem like I can go from absolute url to an absolute url - but I could be wrong. I am new to editing the htaccess file - so I could definitely use some advice here. Thanks.
Intermediate & Advanced SEO | | amberprata0 -
Panda 4.0 Update Affected Site - What should be a the minimum Code to Text Ratio we should aim for ?
Hi All, My eCommerce site got hit badly with the Panda 4.0 update so we have been doing some site auditing and analysis identifying issues which need addressing. We have thin/duplicate issues which I am quite sure was part of the reason we were affected by this even though we use rel=next and rel=prev along with having a separate view all page although we don't concanical tag to this page as I dont' think users would benefit from seeing to many items on one page. This led me to look at our Code to Content Ratio. We have now managed to increase it from 9% to approx 18-22% on popular pages by getting rid of unnecessary code etc. My question is , is there an ideal percentage the code to content ratio should be ?.. and what should I be aiming for ? Also any other Panda 4.0 advice would also be appreciated thanks Sarah
Intermediate & Advanced SEO | | SarahCollins0 -
.htaccess 301 Redirect Help! Specific Redirects and Blanket Rule
Hi there, I have the following domains: OLD DOMAIN: domain1.co.uk NEW DOMAIN: domain2.co.uk I need to create a .htaccess file that 301 redirects specific, individual pages on domain1.co.uk to domain2.co.uk I've searched for hours to try and find a solution, but I can't find anything that will do what I need. The pages on domain1.co.uk are all kinds of filenames and extensions, but they will be redirected to a Wordpress website that has a clean folder structure. Some example URL's to be redirected from the old website: http://www.domain1.co.uk/charitypage.php?charity=357 http://www.domain1.co.uk/adopt.php http://www.domain1.co.uk/register/?type=2 These will need to be redirected to the following URL types on the new domain: http://www.domain2.co.uk/charities/ http://www.domain2.co.uk/adopt/ http://www.domain2.co.uk/register/ I would also like a blanket/catch-all redirect from anything else on www.domain1.co.uk to the homepage of www.domain2.co.uk if there isn't a specific individual redirect in place. I'm literally tearing my hair out with this, so any help would be greatly appreciated! Thanks
Intermediate & Advanced SEO | | Townpages0 -
Can anyone tell me if this website was built with Frontpage or another cookie cutter drag and drop website creator by looking at the source code?
Can anyone tell me if this website was built with Frontpage or another cookie cutter drag and drop website creator by looking at the source code? http://naturespremiumpestdefense.com/ Thanks, Russell
Intermediate & Advanced SEO | | ULTRASEM0 -
Is text that is burned into the code stronger than text that is retrieved from the DB?
Hi, Do you think that texts that are written inside the file's source code get more attention / more credit from Google than texts that are brought from the DB? Thanks
Intermediate & Advanced SEO | | BeytzNet0 -
301 redirect via htaccess question
So, I have www.sitea.com and www.siteb.com I want to redirect SOME pages from www.sitea.com to www.siteb.com (example: www.sitea.com/plugins/wp/ to www.siteb/wp/ etc ) and the rest of any pages left, to the homepage of www.siteb.com. It is something with conditions... any help, please?
Intermediate & Advanced SEO | | jasmin280 -
Proper use and coding of rel = "canonical" tag
I'm working on a site that has pages for many wedding vendors. There are essentially 3 variations of the page for each vendor with only slightly different content, so they're showing up as "duplicate content" in my SEOmoz Campaign. Here's an example of the 3 variations: http://www.weddingreportsma.com/MA-wedding.cfm/vendorID/4161 http://www.weddingreportsma.com/MA-wedding.cfm?vendorID=4161&action=messageWrite http://www.weddingreportsma.com/MA-wedding.cfm?vendorID=4161&action=writeReview Because of this, we placed a rel="canoncial" tag in the second 2 pages to try to fix the problem. However, the coding does not seem to validate in the w3 html validator. I can't say I understand html well enough to understand the error the validator is pointing out. We also added a the following to the second 2 types of pages <meta name="robots" content="noindex"> Am I employing this tag correctly in this case? Here is a snippet of the code below. <html> <head> <title>Reviews on Astonishing Event, Inc from Somerset MAtitle> <link rel="stylesheet" type="text/css" href="[/includes/style.css](view-source:http://www.weddingreportsma.com/includes/style.css)"> <link href="[http://www.weddingreportsma.com/MA-wedding.cfm/vendorID/4161](view-source:http://www.weddingreportsma.com/MA-wedding.cfm/vendorID/4161)" rel="canonical" /> <meta name="robots" content="noindex">
Intermediate & Advanced SEO | | jeffreytrull1
<meta name="keywords" content="Astonishing Event, Inc, Somerset Massachusetts, Massachusetts Wedding Wedding Planners Directory, Massachusetts weddings, wedding Massachusetts ">
<meta name="description" content="Get information and read reviews on Astonishing Event, Inc from Somerset MA. Astonishing Event, Inc appears in the directory of Somerset MA wedding Wedding Planners on WeddingReportsMA.com."> <script src="[http://www.google-analytics.com/urchin.js](view-source:http://www.google-analytics.com/urchin.js)" type="text/javascript">script> <script type="text/javascript"> _uacct = "UA-173959-2"; urchinTracker(); script> head>0 -
Any ideas for easy code to get rankings live?
I'm interested in gathering some further data for my site. What I would like to do is as well as collecting the search Keyword for users coming to my site, I would also like to gather the search engine position for that keyword LIVE - IE what is the current position of that keyword in the SE at the time the user put in their search. This data will be really useful when digging down on my analysis. Does anyone have any simple ideas of how you would go about implimenting this? Many thanks
Intermediate & Advanced SEO | | James770