.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
-
Code to Redirect Mobile Subdomain to Desktop Site
Hi Everyone, My client is switching from a mobile subdomain to a responsive site. All URLs are the same on mobile subdomain vs desktop so we just need a wildcard rule to redirect m. to www. Anyone have this wildcard redirect code for an .htaccess file? Much appreciated! Dan
Intermediate & Advanced SEO | | kernmedia0 -
Intro to programming/coding for seo
Hello, I am currently a SEO and am looking for an Intro to programming/coding course to help me implement various technical SEO tasks for my clients and the business-as the programming dept will not help me, as they do not see the value of SEO. Could someone pls recommend an online course that would introduce me to basic concepts and also specifically, the information that would help me to enhance our SEO? I would also like to better understand APIs. Thanks so much in advance for your help! Lauren
Intermediate & Advanced SEO | | lfrazer1 -
Code Monitor Recommendations
Hi all, I was wondering if you have any recommendations for a code monitor? We'd like to keep track of any code and content changes on a couple of websites. We've taken a look at Page Monitor: https://chrome.google.com/webstore/detail/page-monitor/pemhgklkefakciniebenbfclihhmmfcd?hl=en but I'm not sure if it tracks code changes? Any suggestions for free or paid tools would be appreciated. Edit: We'd also like to avoid a tool that requires any tracking code changes or anything that involves a database/FTP connection.
Intermediate & Advanced SEO | | ecommercebc0 -
Htaccess Question - Is this the way to go to consolidate?
Hi all, My site seems to have www.xyz.com, http://www.xyz.com, http://xyz.com and other variations! From an old agency doing this. All showing differing backlinks etc. SO I want to merge them so I can just look at one analytics account - with everything combined. I want it just to consolidate all to https:///www.xym.com as the client wants - how do I do this? Does it take long to take effect?? Also I presume in webmaster I'll have to set up the preferred extension? Thanks very much for any advice 🙂
Intermediate & Advanced SEO | | VMLQais0 -
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 -
Modify .htaccess
Hi everybody, I need to modify the .htaccess in order to include a 301 redirect. But I am having some problems with this. I downloaded the file into my computer and then modified it with windows notepad, but when I upload it again to the server it is not working and turns down my website. Even if I do not change anything on it. So I guess there is a problem in the saving process. Any Idea or suggestion? Thanks, G.
Intermediate & Advanced SEO | | SilbertAd0 -
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