.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
-
Status Codes - Deleted URLs
Hi I have a dev team 'cleaning' their database and from what I can tell deleting old URL's - which they say are not in use. I don't have much visibility on how our URLs are managed in the back end of the site, but my concern is these URLs should never be deleted, they should have a 301, 404 or 410. This includes product pages no longer available and category pages - my concern is losing authority. Am I worrying over nothing or is this a big issue?
Intermediate & Advanced SEO | | BeckyKey0 -
.htaccess question/opinion/advice needed
Hello, I am trying to achieve 3 different things on my .htaccess I just want to make sure I am doing it the right or best way because I don't have much experience working on this kind of files. I am trying to: a) Redirect www.mysite.com/index.html to www.mysite.com so I don't get a duplicate content/tag error. b) Redirect mysite.com to www.mysite.com c) Get rid of the file extensions; www.mysite.com/stuff.html to www.mysite.com/stuff This is the code that I'm currently using and it seems to work fine, however I would like someone with experience to take a look so I can avoid internal server errors and other kinds of issues. I grabbed each piece of code from different posts and tutorials. Options +FollowSymlinks
Intermediate & Advanced SEO | | Eblan
RewriteEngine on Index Rewrite RewriteRule ^index.(htm|html|php) http://www.mysite.com/ [R=301,L] RewriteRule ^(.*)/index.(htm|html|php) http://www.mysite.com/$1/ [R=301,L] RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html Options +FollowSymlinks
RewriteEngine on
Rewritecond %{http_host} ^mysite.com [nc]
Rewriterule ^(.*)$ http://www.mysite.com/$1 [r=301,nc] Thanks a lot!0 -
How to format a video sitemap for GWT using Vimeo iframe code
I noticed a thread on this forum about using the old embedd code from vimeo for videos, although I can't see this option in Vimeo in 2013. My Question is I have Iframe embedded videos from vimeo, How do I format a google video site map accordingly? or do I need a custom media player instead?
Intermediate & Advanced SEO | | robertrRSwalters0 -
Does anyone have a BOTW.org promo code for november yet?
Does anyone have a best of the web directory promo code for november yet?
Intermediate & Advanced SEO | | unitedfitness0 -
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 -
Help Needed With .htaccess RewriteRule
Hello Fellow Mozzers, I would really appreciate a little help as I have been banging my head against a wall for the last few hours trying to create a .htaccess RewriteRule. I have around 300 URLs that I need to 301 redirect following a site re-build, they are in groups of similar urls but infortunately not broken down in to folders. Here is an example of a few URLs:- https://www.domain.co.uk/chamaecyparis-lawsoniana-ellwoodii_2.htm
Intermediate & Advanced SEO | | AdeLewis
https://www.domain.co.uk/chamaecyparis-lawsoniana-ellwoodii-200225cm-6670.htm
https://www.domain.co.uk/chamaecyparis-lawsoniana-ellwoodii.htm
https://www.domain.co.uk/chamaecyparis-lawsoniana-ellwoods-gold.htm
https://www.domain.co.uk/chamaecyparis-lawsoniana-lemon-queen.htm
https://www.domain.co.uk/chamaecyparis-lawsoniana-yvonne-200cm-66.htm All of the above URLs need to redirect to a new URL:- http://www.domain.co.uk/chamaecyparis-lawsoniana Here is the RewriteRule that I currently have but it isn't working:- RewriteEngine On
RewriteRule ^(.*)_chamaecyparis-lawsoniana$ https://www.domain.co.uk/chamaecyparis-lawsoniana [R=301,L] Anyone have any suggestions? Thanks
Ade.0 -
Autoapprove code
Hi Is any order for google to track the dofollow blogs? Like intext: for example? Thanks
Intermediate & Advanced SEO | | nyanainc0 -
Resources for how to code pages...
I'm looking for some nuts and bolts ideas about how to best layout the HTML code for a webpage. Can you point to some case studies? Perhaps you've done some testing yourself? This could be folded into the Tom Critchlow's question about what should be included in a updated developers SEO cheat sheet.
Intermediate & Advanced SEO | | 19prince0